- Home /
MouseLook script that points +Y at mouse and rotates on Z
Hi,
I think my title is descriptive enough. All the many mouse look scripts i have found rotate the gameobject on Y, and +Z points at the mouse. Maybe I'm stupid but in my 2d game I cannot get a mouselook script to work that rotates the gameobject on Z, and +Y or even +X points at the mouses position. Keep in mind all of the axis are relative to the character. And the characters -Z points at the camera.
I do hope that was not to confusing as I really need a solution, My brain is empty!
thanks
Answer by Waz · Aug 14, 2011 at 02:23 PM
Make your object face its local +Z. Wrap it in another Transform if you can't change the model. "LookAt" means point-Z-at in Unity. Don't fight that.
Right thats sound logical, I cant change the model and I did not know about this wrapping in another transform. is this difficult to do or is it something like parenting it to an empty?
Exactly that - parent it to an empty, then rotate the child. Then use the parent wherever you used the child previously.
Your answer

Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Convert From C# Into JavaScript Please? 1 Answer
mouse look script 2 Answers
Selecting scene for your main menu 1 Answer
Mouselook Script Parsing Error? 1 Answer