I have been working on this for a while now trying both raycast and OnMouseOver and i think i have missed a step somewhere along the way
I have a 3D model that is set to rotate. I am trying to say when the mouse is over the object (or a mesh collider) then stop rotating. However nothing i have tried in the last 3 hours has worked at all.
on my 3D model i have a mesh colider and a c# script called “rotate.cs”
using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour {
//private button = male;
public bool rotate = true;
void Start() {
}
void Update() {
transform.position = new Vector3 (500, 0, 0);
if (rotate == true) {
transform.RotateAround (Vector3.one, Vector3.up, 20 * Time.deltaTime);
} else {
transform.RotateAround (Vector3.one, Vector3.up, 0);
}
}
void OnMouseOver() {
Debug.Log("Mouse Over");
rotate = false;
}
void OnMouseExit() {
Debug.Log("MouseOff");
rotate = true;
}
}
Can someone go through step by step on how to get this working with either raycast or OnMouseOver event systems.