- Home /
The question is answered, right answer was accepted
Rotating the a NavMeshAgent when going up- or downhill?
Hi.
I am trying to add a simple car to my game, which just follows waypoints on a track. Im using a NavMesh on the track and the car is an NavMeshAgent.
When going up- and downhill, the NavMeshAgent does not rotate along it's X-axis, it remains the same.
How do I find the slope of the underlaying NavMesh and rotate the agent accordingly? Say I do a RayCast or the like from underneath the car and out to the front panel of it. How can I get information on the angle of the NavMesh underneath?
Thanks in advance.
I am trying something like this, but I do not understand why it is not working. The normal is not displayed perpendicular to the Nav$$anonymous$$esh surface. It is actually not displayed at all.
samplePosHit = Nav$$anonymous$$esh.SamplePosition(aiCar.transform.position, out hit, 5.0f, -1);
if (samplePosHit)
{
Debug.DrawRay(hit.position, hit.normal * 20.0f, Color.magenta);
}
else
{
Debug.Log("No point found.");
}
Answer by Vicas · Apr 12, 2013 at 07:26 AM
I solved this by sampling a position on the NavMesh 0.1 units in front of the agent. Then I just used a Transform.LookAt() at that position continuously.
Don't know how good a solution it was, but it worked.
Follow this Question
Related Questions
Possible to edit the movement of NavMeshAgent ? 2 Answers
Find the nearest location and move to a target outside Navigation Mesh? 1 Answer
Way to find closest point in a specific area on navmesh. 0 Answers
CS0246: The type or name space name ''NavMeshSurface'' plz some help 0 Answers
Editing NavMesh Paths? 0 Answers