Hello,
I wrote a simple “Rotate towards target” script and was testing it but for some reason the object that I rotate ends up upside down.
Here is the code: (javascript)
#pragma strict
var target : Transform;
var strength = .5;
var targetRotation : Quaternion;
var str : float;
function Update () {
targetRotation = Quaternion.LookRotation (target.position - transform.position);
str = Mathf.Min (strength * Time.deltaTime, 1);
transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, str);
}
and here is the picture of what is going wrong:
The ship needs to rotate with the front towards the planet in the background but ends up with the front down. I already changed the pivot/origin point in my 3d software (blender) but that doesn’t change a thing…
How do I fix this?
Thanks in advance,
Gijs