Instantiated objects sometimes don't trigger "within range".

ophisquest

New member
Hello im making 2d game where various units battle each other in a platform. recently I had started working on a AI to attack the enemy if in range. things worked fine if i place the prefabs directly on the scene from start, but get really weird when I instantiate them dynamically. In the attached file i set s simple tree, just one of the NPCs triggers the attack. both have the same external behavior tree, and tags are correctly set for them to look for each other as targets. i rly don't know what to do anymore
 

Attachments

  • Capturar.PNG
    Capturar.PNG
    117.5 KB · Views: 3
What does your Within Distance task look like? How are you detecting the objects?

If Within Distance is using a layermask or tag then it will pick up the new objects. However, if you have set the objects specifically on the task then you'll need to update the task when you spawn a new object.
 
What does your Within Distance task look like? How are you detecting the objects?

If Within Distance is using a layermask or tag then it will pick up the new objects. However, if you have set the objects specifically on the task then you'll need to update the task when you spawn a new object.
i see, my "within distance" its just looking for tags, I solved the problem by making a child object that sends the target for my main tree, so in my main tree I just need to change if the target variables changes
 
Top