Friday, 17 May 2013

Very simple moving and rotation

Moving an object:

float y = (float) speed * Time.deltaTime;
transform.Translate(new Vector3(0, y, 0));

Rotation, where Bearing is an Enum I created:
Quaternion target = Quaternion.Euler (0, 0, (float)bearing);
        // Dampen towards the target rotation
        transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * speed);;

No comments:

Post a Comment