- Home /
Question by
Tweets · Aug 09, 2020 at 10:58 PM ·
2d gameaipathfindingnearest
A* Path Finding (AI Destination Setter) Trying to set Target Transform to Nearest tagged Game Object (2D),
In the A* Path Finding script for the AI Destination Setter I am trying to use some form of neared Game Object script to set the target transform to the nearest tagged Game Object. I've looked all around for scripts to locate the neared tagged Game Object and even move to it but cant find anything to change the Target Transform in code. Any help would be appreciated. Thanks ,
Comment
Answer by pderek1 · Nov 22, 2021 at 10:40 PM
Hello, to change target transform in code, you can use:
gameObject.GetComponent<AIDestinationSetter>().target = yourTransform;
Don't forget to use library:
using Pathfinding;