Formation problems (im probobly doing something wrong)

tailevi

New member
So I'm experiencing a problem whenever agents are reaching this task.

the first task:
this task is taking a gameObject from a script as the leader (could be a player or a different agent both have NPC script on the exception happens in both cases).
The leader agent have the same tree as the following agents
and pass it with SharedGameObject to the formation.
The IHaveLeaderGo Task also make sure there is a leader game object before passing it onwards with :

MyLeader.Value = myStats.myLeader.gameObject;
if (myStats.myLeader == null)
{

return TaskStatus.Failure;

}

return TaskStatus.Success;

i would very much like to know what am I missing or doing wrong that makes this task not work
 

Attachments

  • myleader.PNG
    myleader.PNG
    34.8 KB · Views: 18
  • theformation.PNG
    theformation.PNG
    57.3 KB · Views: 17
  • theerror.PNG
    theerror.PNG
    39.8 KB · Views: 15
Just to get the basics, does it work correctly if you set the leader manually instead of using a shared variable?
 
when the leader is set manually the task does not throw an exception at all but the agent just stand in place doing nothing.
in my case the leader could be dynamic so i need the shared Variable to work
 
Lets get it working with the manual setting first. Is the formation task active for your leader?
 
Ahh, that would cause it. The follower requires the leader to be active. You can work around this by having the agent be in an idle task (or something related) until an event is sent from the leader tree. This event should be a higher priority task reevaluated with a conditional abort so it'll respond to the leader being set.
 
I understand that solve the case where the leader is placed manually
There is still The dynamic problem.
The task is only filled when the leader is nearby and the leader is decided on the spot at that given moment, which means a group of agents can just be standing around and a leader will pass by a task will be activated adding it to thair NPC script which allows them to use the wadge formation. (the leader also have the formation on him)
 
When you assign the leader SharedVariable couldn't you also send the event notifying the followers that the leader has changed?
 
I haven't had a situation when the leader has switched cuz the leader is determined to the follower by itself

for a batter understanding of what's happening it works like this:

1) a random amount of followers spawn every 15 second

2) each of them has a task that searches for an agent with a higher rank than them then store them in a script on them called NPC, that tasks can only be reached when the leader object in the script is null.

3) Only when the Leader object is not null he can reach the formation task, so the agent never reached the formation before.
 
When do you set the leader object? It's at this point that you'll want to also send the event.
 
Ok, so at that point you can then receive the event within your behavior tree and switch to the formations task. Does that make sense?
 
Top