|
Post by zlblue on Jan 6, 2017 21:31:29 GMT
hello, I set AI's tag to Enemy, and set AI can damage other AI(with the same tag).Since the weapon's hitbox is very big, it may damages itself. so i dont wanna AI damage to itself, is it possible to make it work? Best, Zl
|
|
|
Post by Chronicman on Jan 6, 2017 22:55:32 GMT
Simple mate, Open up vObjectDamage we are gonna need to add two lines of code. First Using Invector; at the top. Second find the onTriggerEnter function and change the first if statement with this code. if (useCollision && GetComponentInParent<vCharacter>().gameObject == hit.gameObject) return;
We are grabbing the vCharacter class from the parent because both AI and Player both have this class, then we compare the two game objects to make sure they don't match. If they match return the void OnTriggerEnter.
|
|
|
Post by zlblue on Jan 7, 2017 7:02:23 GMT
Simple mate, Open up vObjectDamage we are gonna need to add two lines of code. First Using Invector; at the top. Second find the onTriggerEnter function and change the first if statement with this code. if (useCollision && GetComponentInParent<vCharacter>().gameObject == hit.gameObject) return; We are grabbing the vCharacter class from the parent because both AI and Player both have this class, then we compare the two game objects to make sure they don't match. If they match return the void OnTriggerEnter. thank you so much! gonna check it later!:P
|
|
|
Post by Chronicman on Jan 7, 2017 18:46:21 GMT
I kinda messed up what I was trying to say... We are grabbing the vCharacter class from the parent because both AI and Player both have this class, then we compare the parents game object with what ever entered the colliders game object. If they don't match we know they it has not entered its self. If the do match we will return the void to end it before the rest of the code is used, this will prevent your AI hitting it's self.
|
|