orienting navmesh to the normal surface of the ground experiences jerky motion

Hello devs, how are you doing, i’m facing a bit odd problem here, I’m using navmesh agent on my traffic car which has to move upwards and downwards on elevated track paved on terrain, I’m calculating normal of the surface and orienting my car with the normal of the surface, it does get oriented to the surface of the road but when ever it orients to the level of the surface,it experiences some jerky motion

I’m using quaternion.slerp for rotating vehicle from its current orientation to the level of the normal calculated, but i see no impact of as if during play mode while playing is paused, i drag the vehicle above the surface in the scene view and rotate it , and when i move the next frame, all of the sudden it gets oriented to the level of the ground, means no interpolations based on time.

using UnityEngine;
using System.Collections;

public class TerribleAi : MonoBehaviour {
    public Transform[] destinations;
    NavMeshAgent Agenti;
    public int destinationcounter = 0;
    public int initialwaypoint = 0;

    public RCCAIWaypointsContainer waypoints;
	// Use this for initialization
	void Start () {
        destinations = waypoints.waypoints.ToArray();
        Agenti = gameObject.GetComponent<NavMeshAgent>();
    Vector3 temp;
    Vector3 myrotation;
    Quaternion rotation;
    float distance;
	// Update is called once per frame
	void Update () {
        RaycastHit hit;
        Debug.DrawRay(transform.position, -transform.up * 5f, Color.red);
        if (Physics.Raycast(transform.position, -transform.up, out hit, 2f))
            if ( hit.transform.gameObject.layer == 8)
                 temp = Vector3.Cross(hit.normal, transform.forward);
               myrotation = Vector3.Cross(temp, hit.normal)*Time.deltaTime;
               rotation = Quaternion.LookRotation(myrotation);
             // transform.rotation = rotation;
               transform.rotation = Quaternion.Slerp(transform.rotation, rotation,  3f);
                Debug.Log("Applying rotation");


        distance = Vector3.Distance(gameObject.transform.position, destinations[destinationcounter].position);
        if (distance <=2f)

it experiences jerky movement while going down the hill. what wrong am i doing here?

A couple things stand out to me:

1.) You’re multiplying the ‘myrotation’ variable by Time.deltaTime, but that only multiplies it’s magnitude… it should be a unit vector for what it’s used for.

2.) In your Slerp call, you use 3f for the value of t. But the docs say that should be clamped to [0,1]. The reason is because 1 means instant change, while zero means no change. So, by setting it above one, you’re basically making the call redundant.

@FortisVenaliter thanks for replying in details, I looked into my script and altered it, I’m not multiplying myrotation by Time.deltaTime any more, i also decremented the the value of t in slerp to 1 and tried 0.5 even still no luck.

the slope is continuous, can it happen due to lag in applying the calculated rotation to the current rotation, i mean, by the time the calculated rotation is applied, the vehicle is translated to another position for which the normal of the surface might differ from the previous one, I’m sorry if it makes no sense, how ever i tried using Rotatetowards, calculated angle between current rotation and calculated rotation and supplied that as a maxDeltaangle to Rotatetowards but no luck…