I'm on my unity (iPhone) learning curve and working on a arcade shooter game...
I want to use a billboard/sprite prefab for weapon projectile.
I will instantiate this prefab when the player presses the fire button.
I would like the prefab to have the following characteristics:
- use a sequence of tga files (named X0001.tga, X0002.tga, X0003.tga, etc) to create an animation
- I want to use tga files for transparency but if better option pls suggest
- I want control over the "frame rate" for the tga files
- The billboard should always face the camera.
- I will use transform.position to move the projectile in the direction fired
Not finding much documentation on creating a billboard (sprite) based prefab but perhaps I not searching correctly.
Can someone point me to documentation or provide some guidance?
Thanks for any help!
Make a billboard mesh to use for your object and use a script with Transform.LookAt to make it look at the camera in every Update.
As for doing sprite animation, search for sprite animation. (You'll probably find that putting all the animation frames into a single texture and using UV offsets to animate is a more common method to use than using separate images.)
This assumes you've put everything onto a texture atlas and you have 64 frames of animation... I wrote this while mildly drunk, and you'll need to put a transform.LookAt(camera.position) sort of dealio on it. I'm sure you'll figure it out :)
You could easily make this work with any number of frames.
private var frame = 1;
private var xOffset = 0.0;
private var yOffset = 1.0;
private var waterMat : Material;
private var on = true;
function Start()
{
animWater();
}
function animWater()
{
while (on)
{
// Offset the X
xOffset += 0.125;
if (xOffset>0.99) // if it goes over one, return carriage :P
{
xOffset = 0.0;
yOffset -= 0.125;
}
if (frame>62) // Max number of frames reached
{
xOffset = 0.0;
yOffset = 1.0;
frame = 0;
}
frame ++;
renderer.material.mainTextureOffset = Vector2(xOffset,yOffset);
yield;
}
}