PDA

Click to See Complete Forum and Search --> : Trying to find formulas for Projectile Motion..



Ian424
09-14-2002, 10:31 AM
I've done a Google search, the results weren't that great.. Does anyone know a site to go to for a simple formula for a projectile (such as a cannonball from a cannon), that would be easy to apply to flash?

Dickee
09-14-2002, 03:12 PM
Hey Ian424!

Here's some great links for projectile motion:

The Physics Classroom: Vectors and Motion in Two Directions:
http://www.glenbrook.k12.il.us/gbssci/phys/Class/vectors/vectoc.html

Newtonian Mechanics: Force and Motion:
http://www.gamedev.net/reference/articles/article437.asp

Were-here thread: Projectile Motion OK:
http://www.were-here.com/forums/showthread.php?threadid=78332

Jobe Makar used to have a great tutorial up, but I can't seem to find the new addy for it (a Jobe nudge to purchase his book perchance? :D)... I'll post the old link and his new main site for you to search yourself:
http://www.ultimatearcade.com/1_new/tut/Projectile_Motion.html
http://www.electrotank.com

Richard

Ian424
09-14-2002, 04:08 PM
thanks - this has been very helpful because it actually explains things instead of saying something like x=xiv*g*t^2 with no help.. i was able to make a simple 2 direction example.. now i'm working on using angles and maybe having collision detection for bouncing.

if i make anything decent i'll be sure to post :)

DarkMagicHacker
09-14-2002, 04:18 PM
The easiest way to do projectile motion is this...



onClipEvent(load)
{
// these are the initial speeds for the MC
xspeed = 7;
yspeed = -5;
}
onClipEvent(enterFrame)
{
// this lets the computer caluculate x and y
_x = xspeed + _x;
_y = yspeed + _y;
// slows down xspeed and yspeed
xspeed = xspeed * 0.9;
yspeed = yspeed * 0.9;
// if the projectile hits the floor, it bounces
if(this._y>400)
{
yspeed = -yspeed;
}
}


That should work.

Ian424
09-14-2002, 06:00 PM
but its not very easy to set up the same rules over multiple clips that way - w/ the links provided by Dickee, i could have a global variable for gravity and change it quickly for the whole movie :)


i can do the easier methods, i just want to try out some more complex methods

Ed Mack
09-19-2002, 04:40 PM
Here's my sort of cheat way (though it's realistic enough for me):

http://ed.gamegeared.com/flash/bullet2.swf (Click to shoot)
http://ed.gamegeared.com/flash/bullet2.fla

I just have a vx and vy for each shot, and make the vx smaller each time via vx *= .97 and also simulate gravity vy += .5 Then I use arctan to make it point the right direction.

Aware0
09-22-2002, 02:30 AM
Just a organization question...

Would this be better done in FOOP(Flash Object Oriented Programming) style?

I would think that you just create one engine to handle all the physics, then mayve just "launch" the object, and the engine takes care of the physics...

I probably sound stoned :-D...sorry....

brutfood
09-28-2002, 06:55 AM
Originally posted by DarkMagicHacker
The easiest way to do projectile motion is this...


Where does this come from? How was it derived? Where's gravity? (-gt*t/2)

I was taught those parametric sin and cos equations. but I like Ed's approximation.

Fadzter
10-09-2002, 07:58 AM
Originally posted by brutfood
Where does this come from? How was it derived? Where's gravity? (-gt*t/2)
I was taught those parametric sin and cos equations. but I like Ed's approximation.
he's actually not using gravity but rather decreasing the speed by 0.9 for each frame that's executed in the movie.

CrazyElk
10-11-2002, 01:11 AM
DarkMagicHacker has basically simulated friction (air resistance) in a weightless (zero g) environment. Just remember that the main components of this puzzle are going to be:

1) vertical and horizontal start positions (_y and _x)

2) vertical and horizontal speeds (ySpeed and xSpeed), which are added to _y and _x every frame

3) gravity, which increases vertical speed downward each frame (ySpeed += 1)

4) air resistance (a more complicated equation not used in simple Newtonian physics, but easily simulated with vertical and horizontal drags as in xSpeed *= .9)

5) any ground constraints, and bounce factors (does ySpeed become zero when y >= 500, or does it become ySpeed *= -.5)


Based on those things you can put together a very simple projectile simulation which will be very similar to the one DarkMagicHacker gave you.

mike_flashmx
10-18-2002, 09:51 PM
Deleted.