AI Destination Setter Target Value updates in Debug but not in Inspector during Gameplay

I have a piece of code which once it is triggered the AI Destination Setter target changes to a New Destination. My problem is that in the Debug it changes the Destination but in the Inspector during Gameplay when the object is triggered the Target wont change. Any help appreciated. Thanks in advance

Hi

So you mean that if you change the inspector to the debug view the target changes properly, but when it is in the normal view it does not?
Does the behaviour destination seem to change even though the inspector does not change (i.e. does it move towards the correct target)?

Thanks for your reply. In the Inspector it wont let me change it during runtime. No it doesn’t move towards the New Target it just keeps moving towards the first target.

Wait. I thought you were changing the target via a script (original post) and not via the inspector?

No your’e right i am changing it from the script… i just told you that even from the inspector i can’t change it

Hope you can help me with this problem cause I’ve been weeks trying to solve it and the code looks good.
Thanks a lot

That’s strange. Can you change it from the inspector in any of the example scenes?

Can i talk to you somewhere in private to show you the rest of the code maybe you can understand better?
Thanks a lot

When i change it from the inspector during runtime it changes but it instantly reverts back to the old target

Was this in the example scenes or in your scene?
If it was in your scene then it very much sounds like you have another script that is constantly setting the destination. Try to disable other scripts until it doesn’t happen anymore.

Ok ill try it. I am trying it in my Scene. I am doing a Pacman game just to know. This is the part where the pacman eats an energizer and the enemies go to another waypoint

And if i disable the targetMover script of the Pacman which sets the enemies to follow him… then nothing would work

Hi

Do you think you could post that target mover script?

Yes i’ll post it here… I am using a Custom target Mover (Robots are the Enemies)

Hi

I don’t see anything there that would prevent the pacman from changing its target. However one thing that I do see is that you are calling SearchPath every single frame. Normally the AILerp script will automatically recalculate its path asynchronously a few times per second (controlled by the repath rate field). When you call SearchPath every frame, it is possible that you will call it before the previous path has finished calculating and that will then discard the current path calculation and start a new one. It is possible that it never has time to calculate a path completely and that may cause your agents to never (or very rarely) update their paths. If you have path logging enabled you would have seen this in the console as warning messages.
I would recommend that you remove the SearchPath calls except at times when you really want the agent to recalculate its path immediately.

Furthermore I note that your first script (EatObject) sets the destination of “enemy1”, not the pacman. The destination of enemy1 is also set every frame by the target mover script so any change by the EatObject script would instantly be reverted.

Thanks for the reply. So if i understanded well… I’ll just leave 1 Search Path or remove it completely? and change the Enemy1 to pacman. Right?

Remove all of them. The AILerp scripts can take care of recalculating their paths themselves. Use SearchPath only if you have for example changed the destination and you want to make it react very quickly (i.e. you don’t want to wait until the next automatic path recalculation). You can control how often they recalculate their paths using the repath rate field.

I think that the EatObject code is correct cause i need to change the Target of the Enemy not the Pacman

Well, then your target mover script is incorrect because that script will set the destination of enemy1 to the pacman every single frame. You can’t have both.

Oh yes you’re right so what can i do in this case? Cause i really got confused now