Transform.rotation using Quaternion.Slerp Change transelate speed

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);

}

Yeah, multiply the translation values by something. What exactly did you try?

“Didn’t work” is not helpful information. We have to know what it did do, and how that was wrong.

Hi Louis,

I multiplied the translation with the var speed.
There was no change in speed when i uped the value of the speed variable.

x = Input.GetAxis(“Horizontal”) * Time.deltaTime * speed;

Somehow it works now. I created a new object and added this scipt to the obj and it works.
Strange that it works now. :slight_smile:

Thanks for the help!