- Home /
stop rotation when mouse cursor hovers over model
Hi, Just started using Unity as of yesterday and learning Java Script for the first time and have come up across my first problem.
I have got a model that is rotating continuously and I want the rotation to stop when the mouse cursor hovers over the model and then continues the rotation when the mouse isn't hovering over it no more.
would be grateful for any feedback. thanks.
Answer by Yoerick · Nov 11, 2010 at 11:11 AM
You could use the functions OnMouseOver and OnMouseExit along with a boolean like so:
bool rotateObject = true;
void Update() { if(rotateObject) //rotation code }
void OnMouseOver() { rotateObject = false; }
void OnMouseExit() { rotateObject = true; }
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Help with upside-down rotation 2 Answers
Need help with the movement+rotation C# script 1 Answer
90 degrees isnt? 2 Answers
Having player look at mouse in a third person perspective? 0 Answers