A Flash Developer Resource Site

1. ## Projectile Motion

I'm taking general physics this semester and try to put whatever i learn
there into flash with some succsses, but i'm not really pleased with the effect from the projectile motion.
the formulas i'm using right now are
vx=vel*Math.cos(angle*Math.PI/180);
vy=vel*Math.sin(angle*Math.PI/180);
where vel is v0 and a negative angle from 90 to 0;
also;
ball._y =(ball._y)+(vy * t) + (0.5*g*t*t);
ball._x= (ball._x)+vx*t;
where g=9.8 and t is an interval of time starting with 1 and incremeting by 0.2

it makes some kind of a trajectory but well it's not perfect, it's suppost to take the same time to come down as it takes to go up and i don't think it does. Have a look on the file bellow and any idea, suggestion, correction would be great
thanks

ps: i know there is a physic section but i like ppls opinion better in this one. I hope thats ok :P

2. Originally Posted by AluminX
ball._y =(ball._y)+(vy * t) + (0.5*g*t*t);
ball._x= (ball._x)+vx*t;
where g=9.8 and t is an interval of time starting with 1 and incremeting by 0.2
You've almost got it, the only problem is that in the formulas you're using,
d = v0(t) + (1/2)(a)(t^2)
d = vt
'd' is absolute, not relative. You're adding each 'd' (ball._y/x) to the previous one, so just take away the ball._y and ball._x that you are adding in there.

Here's a little experiment i did to make sure what i'm telling you is true:
Code:
```var v0 = -100; //initial y velocity
var vx = 20; //constant x velocity
var a = 9.8;
var t = 0;

this.onEnterFrame = function () {
t+=0.2;
ball._y = Stage.height + v0*t + 0.5*a*t*t; //Stage.height makes it start at bottom instead of at top (0)
ball._x = vx*t;
}```
Your first example, with the vx and vy, is correct if you want to convert a velocity into its x and y components, but changing the angle every frame would probably be just plain weird

btw, I'm taking Physics right now as well.

~MD

3. This is a little time based animation example I created and it includes full and accurate gravity as well:

http://www.electrotank.com/junk/mike/flash/

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap