Mouse touches gameobject, how to make it vibrate ?

Hello everyone, help needed again. I am currently creating a mini game. I got a problem here. When the mouse arrow touches the gameobject, it will start to vibrate, implying there is a clue in it. Is it possible ???

I’m 100% sure it’s possible and I’m guessing you can do it in a number of ways.

2 approaches come to mind:

  • You could animate the object vibrating in a 3d application and then just play the animation when you touch the object.

  • Or You could fiddly with the position and rotation of the object inside unity to make it look like it’s vibrating.

Not sure which method is to be preferred. Some cool noise functions could probably produce a convincing vibration inside Unity although I’m sure just animating it in a 3d package will give the best result and provide you with the most flexibility.

Personally I would animate it because I’m thinking a scripted vibration could end up looking a little static and unnatural.

yes, i was thinking of that too. i intend to animate it using Cinema4D . dont know if there is any script available in unity to make it happen(script of when the mouse cursor touches the game object)

here ya go:

Animate on Mousover

var isAnimating=false;
var ani: Animation;
function OnMouseOver()
{
if(!isAnimating)
{
ani.Play();
isAnimating=true;
Invoke("Over",ani.clip.length;
}
}
function Over()
{
isAnimating=false;
}

just set your ani to your animation, and make sure this script is on your collider, and it will do it