Hey guys, I’m doing a 3D prototype to test some mechanics, and I was playing with stealth. My scene is compounded by 5 enemies, 1 barrel and 5 USB (the way to win is to get them all).
My problem comes with enemies. There are 2 floors, and enemies from 1st floor work properly, but not enemies from 2nd.
They are structured like this:
Empty GameObject used to rotate all from a centered pivot.
AI 3rd Person Controller GameObject from Unity Standard Assets (containing what comes with the prefab + a box collider set on trigger tagged as “Aggro”)
So, the “AI 3rd person controller” has a script to follow a target, in my case my player, which is disabled, and whenever the player enters the trigger, that script activates and set the target on the player. This is working fine on 3 enemies on the 1st floor, but not on both remaining on the 2nd one, which makes no sense as all them 5 are copies of themselves, nothing but name (to find them on another script) changes.
I’ll link a video down below so you can properly see what I mean.
Well, there are only two possibilities I can think of. Either the trigger isn’t functioning, or the script isn’t doing what it’s supposed to do. So, maybe have a visual way to see if the trigger works, like something changes color or whatever. If the trigger is functioning, then something in the script is apparently working differently for some reason, assuming it is being enabled, which you would have to test. I can’t think of any reason it would behave differently because of the floor, but there must be some reason, or it’s coincidental because of the number of clones. You could try changing the order or something, but there aren’t very many. I would guess something has changed the script follow in some way, or the trigger is behaving differently for some reason. Does it do the same if you start upstairs?
The problem is the trigger, which doesn’t activate at all (I’ve been trying with Debug.Log). Also, there are some times that it activates changing nothing, doing exactly the same as when it doesn’t. I’ve been checking it with some friends and no one can explain why is it happening. The last thing I will try is changing where the activation is, from Player’s script to a new enemy script.
You have to find out what’s different about the trigger when it’s upstairs. There has to be something. Maybe it’s in constant contact with something. You may be able to set up a layer so only the character sets it off.