Problem with transform.position

 0 Hello everyone ;) I have this script: ``````var Speed : float = 0; var MaxSpeed : float = 10; var Acceleration : float = 10; var Deceleration : float = 10; var rotateSpeed = 25.0; function Update () { if(Input.GetKey("a")) { transform.eulerAngles.y -= rotateSpeed * Time.deltaTime; } if(Input.GetKey("d")) { transform.eulerAngles.y += rotateSpeed * Time.deltaTime; } if ((Input.GetKey ("s"))&&(Speed < MaxSpeed)) { Speed = Speed - Acceleration * Time.deltaTime; } else if ((Input.GetKey ("w"))&&(Speed > -MaxSpeed)) { Speed = Speed + Acceleration * Time.deltaTime; } else { if(Speed > Deceleration * Time.deltaTime) { Speed = Speed - Deceleration * Time.deltaTime; } else if(Speed < -Deceleration * Time.deltaTime) { Speed = Speed + Deceleration * Time.deltaTime; } else { Speed = 0; } } transform.position.z = transform.position.z + Speed * Time.deltaTime; } `````` Simple yet quiet effectivt... The problem is that I want my character to turn, wich I have done using `transform.eulerAngles` The problem is that, my character moves along the "World axes" no matter how he turns he will still move in the world z-axes if I press "w" If he faces backwards ind a press w(forward key) he still moves along the world z direction. So my question is is there a way to get my charcter move along his "Local axes" instead of the "World/global axes" more ▼ asked Feb 26 '11 at 01:03 PM OrangeLightning 5.4k ● 47 ● 57 ● 112 Bunny83 45.2k ● 11 ● 49 ● 207 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 First: Don't increment or decrement eulerAngles. If they are out of bounds [0..360] you get an error. Use Transform.Rotate instead. And for the position use localPosition or Translate more ▼ answered Feb 26 '11 at 01:13 PM Bunny83 45.2k ● 11 ● 49 ● 207 Thank you got it to work now. Thank you...again ;) Feb 26 '11 at 01:30 PM OrangeLightning add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x1367
x885
x134
x134
x30

asked: Feb 26 '11 at 01:03 PM

Seen: 1151 times

Last Updated: Feb 26 '11 at 01:16 PM