- Home /
Unable to Rotate Navmesh Agent to simulate ball movement. Other possible ways?
Super noob question. A little ashamed I haven't been able to figure this out lol. So I have a ball I'm trying move with the help of Navmesh Agent. Unfortunately, when it moves it just slides around and doesn't actually roll. I understand that I could just write a script for movement but I want to utilize the obstacle avoidance. I am trying to get a grip on this whole navmesh stuff so I would much rather use it. Would I have to use a ball animation (which I am awful at animating lol) or is there some setting to animate physics?
Thanks in advance!
Answer by hrishihawk · Mar 12, 2018 at 12:31 PM
When you want to rotate anything that has an rigidbody attached to it, you can use Rigidbody.AddTorque. And this video will give you little more insight on using it properly.
So I attempted using transform to rotate because of the navmesh/Rigidbody glitch issues that come about when mixed together. So to explain better, I have a ball following the player which I can control. I set the stopping distance to 50 so when the ball (navmesh agent) starts to follow me the forward rotation also begins. I was hoping this would simulate the ball moving and rolling. Unfortunately, I can only get it to rotate left and right and not forward as if it was moving. I am assu$$anonymous$$g it is the navmesh. Just wondering if this is still possible or if I have to make an animation for it.
UnityEngine.AI.Nav$$anonymous$$eshAgent agent = GetComponent();
agent.destination = Player.position;
if(agent.stoppingDistance>50)
{
agent.transform.Rotate(Vector3.forward * 10);
}