void Update()
{
// calculate the displacement since last frame:
Vector3 dir = transform.position - lastPos;
lastPos = transform.position; // update lastPos
float dist = dir.magnitude;
if (dist > 0.001f)
{ // if moved at least 0.001…
dir /= dist; // normalize dir…
float vel = dist / Time.deltaTime; // and calculate current velocity
// bank in the direction of movement according to velocity
Quaternion bankRot = Quaternion.LookRotation(dir + factor * Vector3.right * vel / maxVel);
transform.rotation = Quaternion.Lerp(transform.rotation, bankRot, turnSpeed * Time.deltaTime);
}
}
I want to keep the rotation on the x on 0
The rotation on x is about 45 degrees and it looks like the transform(spaceship is looking at the target).
I don’t want it to lookAt kind of but just to flow to the target position when x axis is on 0 all the time.
Just like when airplane is landing. The front/nose is not pointing the ground like it’s going to crash.
I mean to rotate only on the x to rotate to left or right using lerp but not to make it like lookAt.
Just like spin it to a direction not to change the angle to look at the target.
The nose should be kept same like aircraft is coming to landing.
I think it’s the x axis. Anyway i want to keep spaceship nose at same rotation only to rotate/spin the object.