How would I go about creating an explosion type effect? I have the image sequence, but I’m unsure about how to import it and use Instantiate to spawn it where I want it. Thanks!
You can retrieve a prefab at runtime using Resources.Load. Object.Instantiate actually has a variant that lets you specify the position and rotation of the resulting object.
If your explosion is just an image sequence, you might want to consider using a particle system, and emitting just one particle.
Make a “texture atlas” of your image sequence, so that all the images are laid out in a grid formation within one texture. Then use the Particle Renderer’s “UV Animation” values to specify the number of rows columns you’ve used in your texture atlas. The particle system will automatically animate through your sequence.
For more information about particle systems, start reading here:
http://unity3d.com/support/documentation/Components/comp-ParticlesGroup.html
and this page talks about the UV animation (at the bottom of the page):
http://unity3d.com/support/documentation/Components/class-ParticleRenderer.html
hope this helps!
- Ben
Oh, another method which may be more suitable since you are developing for iPhone - the “Sprite Manager” has similar UV animation functions to Unity’s particle system, so if you’re not already using it, you should definitely look into it.
Both the particle system method and the sprite manager method should allow you to draw multiple explosions in a single draw call.
- Ben