Support Forum

DestinationSetter with player made up of different characters

Hi Team,

So i have just started using the project and finding it fantastic. However i have one problem. My player is made up of 2 characters. Only one of them being active at one time. I have attached the destination setter to my enemy but it can only track the one player. How can i do it so that the destination is dependant on which character is active?

Thanks in advance!

Hi

This would be a simple matter of just setting the aiDestinationSetter to another transform when you need it, wouldn’t it?

Note that you can also remove the AIDestinationSetter script and set the ai.destination property directly. This might be more intuitive in some scenarios.

Hi Aron,

Thanks for replying.

Indeed, to deal with it in other situations, I am just accessing the Class that holds which player is active. However It will not let me access it as i normally would through the AI Destination setter script. I thought this might be because it is using the namespace Pathfinding. This is the part that is confusing me.

You cannot access other classes because you are modifying a script in the pathfinding package. These cannot access scripts outside it.

I would recommend that you use a separate script and do something like

void ChangeTarget () {
    GetComponent<AIDestinationSetter>().target = someValue;
}

or you can remove the AIDestinationSetter and use the destination property directly.

void ChangeTarget () {
    GetComponent<IAstarAI>().destination = someCoordinate;
}

Ah, I see.

Thanks for the suggestions. I used the first as i felt I should keep the A8 script whilst i start out with it.

Thanks again for your help.