I’m building an animated main menu for my game and I was wondering how I would get it so that when the mouse hovers over the object it moves forward 1 unit, and stops. No more, I have only got it so that it will keep moving forward while the mouse is on it. The only other solution I can think of is placing an invisible wall that it will stop on contact. But if anyone has a proper solution I’d be ecstatic to hear it! Here’s my code!
var pLight: Transform;
private var enableLight: boolean = false;
pLight.light.enabled = false;
function OnMouseOver () {
renderer.material.color -= Color(0, 0, 100) * Time.deltaTime;
pLight.light.enabled = true;
}
function OnMouseExit () {
pLight.light.enabled = false;
}