I have an animation. See the attached GIF.

During the game I have one of those other spheres, which have navmeshagents, move to the location of the “invisisphere,” or the object moving in the animation, set it as their parent, and then play the animation. However, they don’t move when this happens. Shouldn’t they be following the actions of their parent or the moving sphere?
I understand this may be happening because the navmeshagent can’t move off of the navmesh. How do I tell it to do that so the animation can play correctly?
I tried doing “agent.enabled = false;” (agent being my variable for the navmeshagent) but it didn’t work.
agent.enabled = false; should actually work, not sure why it doesn’t. Maybe post some more code?
You could also try
agent.updatePosition = false;
agent.updateRotation = false;
but I doubt it will work if enabled flag is not working.
Okay, I don’t know what I was doing wrong last time. but I got it working. The relevant code is here (the first part is part of a different method):
if (Vector3.Distance(this.gameObject.transform.position, agent.destination) < 1f)
{
if (agent.hasPath == false)
{
Play(currentGO);
Debug.Log("Going to Play!");
}
}
And then…
void Play(GameObject funObject)
{
busy = true;
Debug.Log("Playing!");
action = "playing";
Invoke("NotBusy", 10);
Invoke("Resting", 10);
agent.enabled = false;
this.transform.parent = funObject.transform.Find("Invisisphere").gameObject.transform;
funObject.GetComponent<PlayAnimationScript>().PlayAnimation();
boredEngaged += 10;
sadHappyMood += 10;
}
Apologies and thanks for the tip. I’d given up on this for the moment.