Hi there,
I’m trying to move a spaceship in X and Z and let it Tilt over the Z rotation.
This al works, but i want to change the translation speed.
Ive tried creating a var speed : float = blabla; and multiplied it with the axis values, but that didn’t work
Is there an easy way to change the translation speed?
// Smoothly tilts a transform towards a target rotation.
var smooth = 2.0;
var tiltAngle = 20;
var speed : float = 400;
var x : float;
var z : float;
function Update ()
{
var tiltAroundZ = Input.GetAxis(“Horizontal”) * tiltAngle;
var tiltAroundX = Input.GetAxis(“Vertical”) * tiltAngle;
var target = Quaternion.Euler (0, 0, -tiltAroundZ);
// Dampen towards the target rotation
transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);;
x = Input.GetAxis(“Horizontal”) * Time.deltaTime * speed;
z = Input.GetAxis(“Vertical”) * Time.deltaTime * speed;
transform.Translate(x, 0, z,Space.World);
}