- Home /
Controls Like the Mouse Look. Just without using Mouse
Okay, so I am using mecanim for my player controls and the animations for turning that I have made aren't working the way I had hoped and the animations that come with mecanim aren't suited for my game. I was wondering if there was a simple way (not using Mouse Look) to make my character rotate by hitting D and S (or arrows)? The Mouse Look was perfect but the problem is, I need my mouse for clicking on enemies or lootable items. If the mouse is set up for Mouse Look then all i'll do is rotate my character and not be able to select or click things properly. Thanks in advance!
Answer by sevensixtytwo · Sep 17, 2014 at 12:24 AM
Try Transform.Rotate. MouseLook uses it too. Example:
//JS
//Rotates the transform on Horizontal Axis input
var rotDir = Input.GetAxis("Horizontal");
var rotSpd = 10;
transform.Rotate(Vector3(0,rotDir*rotSpd,0));
It's pretty simple but it'll do what you want.
Your answer
Follow this Question
Related Questions
Need help with scripting for product visualisation! 1 Answer
WASD Movement with Mouse position dictating which way the character is facing 1 Answer
Need help creating certain character control 0 Answers
3d camera control 3 Answers
camera movement in world space, but when the rotated on y axis 1 Answer