PDA

View Full Version : spriteTwistPP depended on


iantreefish
01-21-2008, 02:22 PM
Hello all,

I'm currently trying to make a jet of water with sprites but have run into a problem. I would like the sprites to rotate [automatically] as they fall as the image illustrates

http://i169.photobucket.com/albums/u228/iantreefish/spriteTwistPP.jpg
WARNING: though the arc they fall in should be the same, the picture was just a quick hack job to get the point across...:D


How might I go about doing this? I've tried to figure out how to get the angle from a sprites current point and previous point in time and pass the results to a runtime spriteTwistPP expression but have been unsuccessful so far. Any help would be greatly appreciated!!!

thanks,
ian

Als
01-21-2008, 08:32 PM
From the top of my head something like this should work:

If your sprites are moving up and down ( on Y and X ) and are "flat" on Z axis:


// you might need some of these:
//$an = unit (particleShape1.velocity);
//userScalar1PP = mag (particleShape1.velocity) * .25;
// But this is the thing:

vector $vel = particleShape1.velocity;
particleShape1.spriteTwistPP = atand($vel.y/$vel.x);



Note:
Keep in mind that sprites always look straight to camera:
if you look straight from x or y axis sprites have to turn away
so direction will look wrong...

Hope this works for you...


Als

iantreefish
01-22-2008, 12:54 AM
Thanks so much Als!

Your script worked though you were right about the whole XY view stuff. I guess I'll just have to figure out some other way to make a water jet. I'm trying to make the effect usable in games so being able to move about the jet in 360 degrees is pretty important.

Thanks again though! At least I know now what's necessary and that its doable... somewhat!

CGTalk Moderation
01-22-2008, 12:54 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.