- Home /
Question by
VinXYZ · May 16, 2021 at 03:13 PM ·
aiprogrammingfixedupdatearray of gameobjects
A*: Setting target through script only works once.
I have a script (in FixedUpdate) that's supposed to change the target of a gameobject each time it reaches the current target. It succesfully loops through the array, and it does not run only once, so i know that the path is not null. It just doesn't set the target. Here's the script:
if (powerupPath != null)
{
if (powerupPath.reachedEndOfPath == true || powerupPath.velocity == new Vector3(0, 0, 0) || powerupPath.remainingDistance < 0.1)
{
powerupDestination.target = Waypoints[placepicked].transform;
if (placepicked < 3)
{
placepicked++;
}
else
{
placepicked = 0;
}
print(placepicked);
print(powerupDestination.target);
print("wow");
}
}
Thanks!
Comment
Your answer
