Animating and loading a new object

Hi guys,

I’m trying to use the mouse to click an object, play an animation and load another object to take its place, all after mouse clicking one time. Could someone point me in the right direction? Is there a good tutorial for this?

Thanks,

Greg

Do you want something like this:

function OnMouseDown () {
     animation.Play();
}

What do you mean by “load another object”

Hi Daniel,

I am looking to load an animation after I click an object, then replace it with another object. For example: clicking a cube plays a particle system, then changes the cube to a pyramid.

Okay, place this script onto the cube:

var particleSystem1 : GameObject;
var pyramid : GameObject;
function OnMouseDown () {
     particleSystem1.animation.Play();
     Instantiate(pyramid, transform.position, transform.rotation);
     Destroy(gameObject);
}

Cool, thanks! Would you happen to know how to make the pyramid instantiate at the same coordinates as the cube? At the moment it is placing the pyramid at an arbitrary location, albeit not far away.

Thanks,

Greg

Instantiate (pyramid, transform.postion, transform.rotation);

If you’re using this code, it should instantiate the pyramid at the exact coordinates of the cube, and the exact rotation of the cube.

Sorry man, I must have some strange export issue with Maya or something. When I replace the object with anything else it works perfect. I wonder if it is the pivot point on my pyramid model. Thanks for your help, I appreciate it very much.

-Greg