- Home /
Question by
bl_odymary · May 25 at 05:19 PM ·
scripting beginnerplanenoobtilting
Trying to make my plane tilt on Z axis when turning left or right,Trying to make plane tilt on Z axis when turning left or right
Hi! Noob question here...So, I'm making this game on which I'll have this plane thingy moving through the scenario and I'd like it to tilt on Z axis whenever its moving horizontally. I've tried adding a simple transform.Rotate to the script just to try it but it obviously wouldn't work since I haven't even set the axis it's supposed to rotate on...Can anyone give me a hand? Here's my script:
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 dir = new Vector3(h, 0, v);
transform.Translate(dir * speed * Time.deltaTime);
transform.Rotate(dir * speed * Time.deltaTime);
}
} ,
Comment
Your answer
Follow this Question
Related Questions
Setting GameObject in a script. 0 Answers
flipping animation (I know this is asked alot) 0 Answers
Cannot get position of other objects 2 Answers
Placeable Menu (Hololens) 0 Answers
Creating loud floor panels 1 Answer