x


Playing UV-Animation on a Plane, without particle system?

Want to make a explosion on ONE plane with UV-Animations!

I have tried the particle renderer, which can add UV-Animations ON a particel system. But what i need is a simple plane, which will be added via script, with an UV-Animation (tiled based explosion) on it.

Using a imported Plane with a particle renderer on it, wont work! Using the particle system, brings the particle plane, which is reduced to 1, to popup and vanish somehow around the enviroment. beside the fact i dont want to use particle system. just need a simple plane with uv-animations on it, which will be added via script and a lifetime.

O_O ....thnx for any help!

more ▼

asked Apr 22 '10 at 10:41 AM

SOIL gravatar image

SOIL
89 24 25 33

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I once used this little snippet to animate the UVs of my plane, for a similar purpose:

This was for an 8x8 grid. The 'padding' value determines how much inside the border of each grid cell is actually sampled - to avoid 'bleeding' between animation frames.

It returns a list of two Vector2s. The first is the lower-left corner of the animation frame, the second contains the width and height of the animation frame in UV units.

Vector2[] GetSpriteUVs(int frameNum)
{
    int gridSize = 8;
    float padding = 0.1f;


    int x = frameNum % gridSize;
    int y = (gridSize-1) - (frameNum / gridSize);

    float u = (float)x / (float)gridSize;
    float v = (float)y / (float)gridSize;

    u += (1.0f / (float)gridSize) * padding;
    v += (1.0f / (float)gridSize) * padding;

    float w = (1.0f / (float)gridSize) * (1 - padding * 2);
    float h = (1.0f / (float)gridSize) * (1 - padding * 2);

    Vector2[] uvs = new Vector2[] { new Vector2(u,v), new Vector2(w,h) };

    return uvs;

}

Another option would be to take a look at the SpriteManager script on the Wiki, which has this functionality built-in.

more ▼

answered Apr 22 '10 at 11:01 AM

duck gravatar image

duck ♦♦
41k 92 148 415

Thanx alot! =) i will try this

Apr 22 '10 at 11:43 AM SOIL

Did this solve your problem? (if so, remember to click the 'accept' tick icon, and vote up the answer)

May 16 '10 at 01:55 PM duck ♦♦
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3778
x3328
x638
x250
x237

asked: Apr 22 '10 at 10:41 AM

Seen: 3898 times

Last Updated: Apr 22 '10 at 10:41 AM