# Steering Wheel Problem

 0 Hey I have this code to making a steering wheel: ``````var rotationSpeed : float = 100.0; function Update () { var rotation : float = Input.GetAxis("Horizontal") * -rotationSpeed * Time.deltaTime; transform.Rotate(0, 0, rotation); } `````` It is working ok but I need the steer to comeback to the original position when I stop pressing the arrow keys. How can I do that? I tried using Quaternion.Slerp but I can't define the original position to comeback to. Thanks for any help more ▼ asked May 06 '11 at 03:41 PM maveryck21 239 ● 29 ● 32 ● 44 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 Create a quaternion variable to store the default rotation in local space on awake or start, then you can lerp/slerp just fine from transform.localRotation to that variable. more ▼ answered May 06 '11 at 06:39 PM Alec Slayden 1.2k ● 1 ● 4 ● 15 Yeah you are right, I was using transform.rotation instead of the localRotation, that was the error. Thanks May 07 '11 at 03:54 PM maveryck21 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 My problem is solved thanks to Alec Slayden, here is the code: ``````var rotationSpeed : float = 100.0; static var origRotation : Quaternion; function Awake () { origRotation = transform.localRotation; } function Update () { var rotation : float = Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime; transform.Rotate(0, rotation, 0); transform.localRotation = Quaternion.Slerp(transform.localRotation, origRotation, Time.deltaTime); } `````` more ▼ answered May 07 '11 at 03:56 PM maveryck21 239 ● 29 ● 32 ● 44 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email: