- Home /
Transform.Rotate Not working
float turn = Input.GetAxis ("Mouse X") * turnspeed;
float horiz = Input.GetAxis ("Horizontal");
float vert = Input.GetAxis ("Vertical");
transform.Rotate (new Vector3 (0, turn * Time.deltaTime * turnspeed, 0));
I am trying to make a character turn. I am mapping the axis correctly- I used Debug Logs to checdk- but my character refuses to turn. does anyone have an idea why?
I am not 100% sure about this, but i think you need to define the space to be Space.Self - try this -
transform.Rotate (new Vector3 (0, turn * Time.deltaTime * turnspeed, 0), Space.Self);
It should default to Self space, but you never know, worth a try. I would print out turn Time.deltaTime turnspeed. Also, are you calling this in Update()? Is turnspeed 0? You're already multiplying turn by turnspeed at the top, so multiplying it twice.
A few things strike me as odd:
You get values for vert
and horiz
, but don't appear to use them.
You multiply turn
by turnspeed
while querying input, and then again while applying rotation. Perhaps you only want to multiply that value once?
I don't know the value of turnspeed
.
If any of your input axes are set up incorrectly, you may be getting zero for all of your inputs.
$$anonymous$$ake sure you check the value of 'turnspeed' in the Inspector. Values assigned to public variables are only used when the script is first attached.
Also be sure that your turning code is called from inside the Update() function.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Rotating while rotating? 1 Answer
Navigating the 3D platform 0 Answers