Hello I am trying to blow stuff up. I have an exploded mesh, target mesh and some scripts. I am not sure how to animate the exploded mesh after it’s instantiated:
Instantiate (explodedMesh, transform.position, transform.rotation);
Destroy(gameObject);
//now here I want to make the explodedMesh pop up for a second then smack the ground
//I don't know how to address or call instantiated mesh to add velocity to it
// I tried rigidbody.velocity = transform.forward * speed * 1; but that spawned infinite exploded meshes
I am not quite sure if I understand your question correctly. I hope that you create the explodedMesh as a prefab with the particle system. To do more stuff to the instantiated object, you need to refer to it. For example,
var exp = Instantiate (explodedMesh, transform.position, transform.rotation);
I get a cascade of exp following the velocity direction. It doesn’t seem to create one piece of geometry and move it, instead exp creates an instantiation on every update so there is a lot of exploded meshes popping up in the path of the velocity.
so somehow I need to add velocity to that first piece of geometry that is spawned and move it with velocity somehow without creating additional geometry.
Usually, an explosion is controlled by the particle system. Make sure that you set up your particle system correctly. For example, make sure to check mark the One Shot of Particle Emitter and check mark the Autodestruct of Particle Animator. Just a thought!
The particle system works good but i wanted to add another level of realism by leaving behind some geometry that destroys after several seconds.Just Pieces of an exploded version of what I blew up. I can do that but I wanted to move the geometry as if it Spawns moving after the particles showmup.
Do you want to control the explosion object (for example, grenade) or exported object ( for example, a car)? You may also take a look at the Detonator Explosion framework which you can get it from the Asset Store.
As I see it, the most probable thing this code generates a mesh every frame is that it’s written inside the function Update() or called from that function.