Flight Trajectory - Eary Question
Hi,
How would you calculate a flight trajectory of an object, based on it's rotation.
For example, if _rotation == 0 then it should fly upwards y -= 1 ; x -= 0
if _rotation == -45 then it should fly y -= 1 ; x -= 1
if _rotation == 45 then it should fly y -= 1 ; x += 1
if _rotation == -90 then it should fly y -= 0 ; x -= 1
if _rotation == 90 then it should fly y -= 0 ; x += 1 and so on.
Thanx!
FlashKit > Flash Help > Flash ActionScript
Posted on: 04-21-2004, 01:23 PM
View Complete Forum Thread with Replies
Sponsored Links:
Ball Flight Trajectory
Hi all
I want to create a golf ball flight animation. I have all the datas and formulas I need but I'm struggling on how to animate it.
// Data of an 8 Iron shot
var startX:Number = 0;
var startY:Number = 300;
var maxHeightX:Number = 88;
var maxHeightY:Number = 26;
var landingX:Number = 143.02;
var landingY:Number = 300
var endX:Number = 145;
var endY:Number = 300;
var velocityX:Number = 17;
var velocityY:Number = -18;
var time:Number = 0;
var timeOfFlight:Number = 5.67; //in seconds
var gravity:Number = -9.8+velocityX^2;
//I would also like to add the drag effect (friction)
var friction:Number = 0.3;
//I also have some more datas that could be helpfull
var launchAngle:Number = 33
var horizontalLandingAngle:Number = -7;
var verticalLandingAngle:Number = 82;
// now here is the formula to calculate the actual x and y during the animation..
// the Z is the is the initial direction let put that value to 1 form now.
var theX:Number = velocity * cos(z) * time;
var theY:Number = velocity * sin(z) * time + (gravity/2) * t^2;
I didn't find any GOOD exemples of what I try to achieve so far.
I need help to make the transition beetween the ascending and descending part of the anim. I'm sure that, from here it sould be quite simple, but not for me
Thanks for your time
View Replies !
View Related
Spaceship Flight
I am currently trying to make a simple space type scroller game and i am currently working on making the spaceship fly
I have opened up the thrust space sample and copied the code from there and edited bits , however would like the spaceship to fly up and down more like the way it flys right (forwards)
This is the code i have so far
I am really struggling with making the spaceship strafe up and down the same way it flys forward. whenthe spaceship flies up or down i don't want it to rotate
I have tried copying and pasting the code for the right movement to the up and down bits and altering it however i can't get it to fly up or down
[edit] I would also like to make it so that when the key left is press the spaceship slows down steadily to a stop. (not stop suddenly or stop too slow like it would otherwise)
Please could someone help me
Code:
onClipEvent (load) {
// declare and set initial variables
thrust = 0.1;
decay = .98;
maxSpeed = 25;
}
onClipEvent (enterFrame) {
// rotate right or left
if (Key.isDown(Key.UP)) {
_y -= 10;
}
if (Key.isDown(Key.DOWN)) {
_y += 10;
}
//
//
if (Key.isDown(Key.RIGHT)) {
// calculate speed and trajectory based on rotation
xSpeed += thrust*Math.sin(_rotation*(Math.PI/180));
ySpeed += thrust*Math.cos(_rotation*(Math.PI/180));
flames._visible = 1;
} else {
// deccelerate when Up Arrow key is released
xSpeed *= decay;
ySpeed *= decay;
flames._visible = 0;
}
//
// maintain speed limit
speed = Math.sqrt((xSpeed*xSpeed)+(ySpeed*ySpeed));
if (speed>maxSpeed) {
xSpeed *= maxSpeed/speed;
ySpeed *= maxSpeed/speed;
}
//
// move spaceship based on calculations above
_y -= ySpeed;
_x += xSpeed;
//
// loop to opposite side of the stage when the spaceship travels off-screen
if (_y<0) {
_y = 300;
}
if (_y>300) {
_y = 0;
}
if (_x<0) {
_x = 600;
}
if (_x>600) {
_x = 0;
}
}
Thank you
I hope you understand what i meant
The bits in red are the up and down movement which i would like to be more like the thrust movement
View Replies !
View Related
Spaceship Flight
I am currently trying to make a simple space type scroller game and i am currently working on making the spaceship fly
I have opened up the thrust space sample and copied the code from there and edited bits , however would like the spaceship to fly up and down more like the way it flys right (forwards)
This is the code i have so far
I am really struggling with making the spaceship strafe up and down the same way it flys forward. whenthe spaceship flies up or down i don't want it to rotate
I have tried copying and pasting the code for the right movement to the up and down bits and altering it however i can't get it to fly up or down
[edit] I would also like to make it so that when the key left is press the spaceship slows down steadily to a stop. (not stop suddenly or stop too slow like it would otherwise)
Please could someone help me
Code:
onClipEvent (load) {
// declare and set initial variables
thrust = 0.1;
decay = .98;
maxSpeed = 25;
}
onClipEvent (enterFrame) {
// rotate right or left
if (Key.isDown(Key.UP)) {
_y -= 10;
}
if (Key.isDown(Key.DOWN)) {
_y += 10;
}
//
//
if (Key.isDown(Key.RIGHT)) {
// calculate speed and trajectory based on rotation
xSpeed += thrust*Math.sin(_rotation*(Math.PI/180));
ySpeed += thrust*Math.cos(_rotation*(Math.PI/180));
flames._visible = 1;
} else {
// deccelerate when Up Arrow key is released
xSpeed *= decay;
ySpeed *= decay;
flames._visible = 0;
}
//
// maintain speed limit
speed = Math.sqrt((xSpeed*xSpeed)+(ySpeed*ySpeed));
if (speed>maxSpeed) {
xSpeed *= maxSpeed/speed;
ySpeed *= maxSpeed/speed;
}
//
// move spaceship based on calculations above
_y -= ySpeed;
_x += xSpeed;
//
// loop to opposite side of the stage when the spaceship travels off-screen
if (_y<0) {
_y = 300;
}
if (_y>300) {
_y = 0;
}
if (_x<0) {
_x = 600;
}
if (_x>600) {
_x = 0;
}
}
Thank you
I hope you understand what i meant
The bits in red are the up and down movement which i would like to be more like the thrust movement
View Replies !
View Related
Calculating Flight-curve
Hi,
i want to calculate a flight-curve via Flash.
My script somewhat works but i get strange results on some "angles" i define.
Maybe a Math-pro could help me with that ?
the fla for the flight-curve
thanks
cedrik
View Replies !
View Related
Animating The Flight Of A Butterfly
I want to do an animation of a butterfly in flight. I can do it in a 3d program (ie Maya) but I'm not sure how to do it in Flash as it does not allow transitions on the Z axis. I want a side view like the attached jpeg (The body is not right, I know!). Any suggestions would be appreciated. It doesn't have to be completely lifelike; I'm going for a more simplistic, cartoony look.
Thanks, Tulane
View Replies !
View Related
Animating Flight Paths
hi there i was wondering if anybody knows how to aniamte a flight path.you know when you see a site like the amazing race and they draw lines to indicate that you are traveling to differant continents
I've tried to do it with the brush tool but it does not work properly
pleas can someone offer some advice.It would be greatly appreciated
View Replies !
View Related
Making A Flight Route
hi there
i was wondering if someone could help me make a flight route,i am trying to build this travel website for uni and i want a flight route where it look as if the red line(flight route) is being drawn in.i have tried to use the line tool and then put a tween on it but it is not the effect that i want.
i would really appreciate the help thanks
View Replies !
View Related
My Flight Refuses To Explode..
Hi all,
im trying to make a small game in which the flight wants to explode if the missile ( bullet) hits. But it doesn't happen so?. I spent a couple of days to achieve the same. But i cant. any one pls help me to finish this simple game.
And also it has some other errors such as
after the time elaps the game over page was displayed, but the seconds continues. etc.
Actually this is my very first trial for building games.
Lastly,
What are things needed to build a very attractive games?.
Any suggestions ideas, tutorials are welcome.
pls have a look at my .fla.
My adv thx to everyone.
Jsam...
View Replies !
View Related
Eagle In Flight - Any Suggestions
Hey guys I just got done designing this logo for a client of mine and they want a 5 second intro to their site with the eagle flying in(actually flapping its wings) and then stopping as if in mid-flight and the logo fading in around it. I really dont know what I should do to make this look good outside of finding a movie of a eagle flying and copying its flight using onion skinning. I have included the logo for you guys to check out. But if anyone knows of any tutorial or sites I could check out that would be great. Also if anyone has a better idea how the intro should go that would be great too.
Thanks again,
Chris
PS. I realize I ask for help far more often than I give it something im hoping to rectify. But thank you all in adavance.
View Replies !
View Related
Eagle In Flight - Any Suggestions
Hey guys I just got done designing this logo for a client of mine and they want a 5 second intro to their site with the eagle flying in(actually flapping its wings) and then stopping as if in mid-flight and the logo fading in around it. I really dont know what I should do to make this look good outside of finding a movie of a eagle flying and copying its flight using onion skinning. I have included the logo for you guys to check out. But if anyone knows of any tutorial or sites I could check out that would be great. Also if anyone has a better idea how the intro should go that would be great too.
Thanks again,
Chris
PS. I realize I ask for help far more often than I give it something im hoping to rectify. But thank you all in adavance.
View Replies !
View Related
Trajectory Problem
I am working on a game where you got a cannon on the bottom of the screen that rotates to reflect your mouse position. I got all the rotation working properly, but I would like to add a line coming out that projects the trajectory.
Currently I have the line coming out of the cannon, my problem is getting it to reach the end of the stage and getting to to bounce back to the other side of the stage and repeating until the line will be off the screen. Seems my math mind is getting rusty in my old age.
Here is the code I have on the sample script I am trying to work this out on.
code:
onClipEvent (mouseMove) {
Radians = Math.atan2((_root._xmouse-this._root.arrow._x), (_root._ymouse-_root.arrow._y));
TempTube = Math.round(Radians*180/Math.PI);
if (TempTube>0 && TempTube<110) {
TempTube = 110;
}
if (TempTube<0 && TempTube>-110) {
TempTube = -110;
}
_root.arrow._rotation = 180-TempTube;
_root.targetline_mc.clear();
angle = (180-this._rotation)*Math.PI/180;
xcomponent = Math.sin(angle)*500;
ycomponent = Math.cos(angle)*500;
_root.targetline_mc.lineStyle(1, 0xff0000, 100);
_root.targetline_mc.moveTo(this._x, this._y);
_root.targetline_mc.lineTo(this._x+xcomponent, this._y+ycomponent);
updateAfterEvent();
}
Also I have attached a sample FLA of what I am working on. Basically the script is attached to a simple arrow I made parked in the bottom center of the screen. Targetline_mc is an empty movie clip created in Frame 1.
This has been driving me crazy, I know its got to be something simple I am just overlooking. Thanks in advance for any help you can give me on this problem!
View Replies !
View Related
Basketball Trajectory
Hi!
It's me again
I'm trying to do a basketball game using Flash MX.
Now, I'm trying to find some way to make the ball fly to the basket, from any point on the ground, and make it "credible".
I attach an image... I don't know if it will be helpful!
How do you think it's the easiest way to do that? trying to simulate the real fisics (forces.. gravity... ouch!)? There is any easier way?
thx in advance!
View Replies !
View Related
Trajectory Tutorials
Hi Guys
I am looking to make a simple mini game based on something like this iceslide game. http://www.miniclip.com/games/ice-slide/en/
I have been doing a lot of hunting on the web for tutorials or sample starter code to create such a game but cant seem to find any tutorials on trajectory based games. There seems to be plenty of these games around but no tutorials. If anyone knows of any good places to look that would be great.
Many thanks
Trevor
View Replies !
View Related
AS2 - The Pain - Trajectory.
I hate math.... a LOT. My basics are really shocking and I dont even know/remember what simple math like sin/soc/tan is/does let alone do what I need to.
I need help with a proper simple working example on how to make a cannonball launch from a cannon(side view). Ive tried looking around but dont understand the formula and no one gives working examples. I googled "trajectory actionscript" and came up with pages of examples of the formula and dead sample links.
I would research this but I think the fact that I have the attention span of a fish when reading and have VERY limited time to create this game I need help.
View Replies !
View Related
Star Flight Game Has Some Bugs.
hi. ive recently completed the tutorial on the side scrolling space game, and my game works almost perfectly.
i followed the tut. almost exactly, except there are a few more scenes (start screen, etc.)
well my biggest problem is that when you die and you press replay, i made the button take you to the title screen, where the play button is.
even though it is a different scene, the enemies are still respawning, and it looks really unprofessional. how do i stop the enemies from respawning after i have died? another problem with this is that when you start the game again, if you start it on top of an enemy you die automatically.
there are some other bugs, but this is my biggest.... please help.
View Replies !
View Related
How To Load External Pictures On The Flight?
hi guys and girls
I created the attached Fla in Flash 5.
It's a series of 8 pictures fading in and out. They are embedded in the swf.
I would like to change the fla so that the pictures can be updated/changed in the swf without having to go back to the Fla.
I am not familiar with scripting. Is there a simple way to do that? Practically have the swf linked to external files that can be easily replaced, therefore updating the swf.
I have Flash 5, please suggest something suitable for this version.
Much appreciated
Geo
View Replies !
View Related
Creating Realistic Flight Of An Arrow
I'm trying to put together some code that will approximate the arced flight of an arrow.
Currently, I've got the code so that the angle of the bow movieclip will move depending upon the position of the mouse. Pressing the mousebutton will then fire an arrow at this angle (albeit at a constant speed). I've played around with xmov and ymov in an attempt to introduce inertia and gravity (respectively) and therefore create a more natural flight of the arrow but aren't really getting what I'm after. Added to this, I also need to alter the angle of the arrow clip over the course of it's flight to imitate the charge in orientation (i.e. starts to point towards the ground in the downward 1/2 of the arc). Code so far is below.
Does anyone have any suggestions? Or even alternatives (such as draw a curve with the curveTo method and then animate the arrow clip along this path? ... LOL, or is this simply wild/hopeful speculation on my part)
speed = 25;
// calculate angle based upon mouse position
_root.onMouseMove = function() {
updateAfterEvent();
xdiff = _root._xmouse-bow_mc._x;
ydiff = _root._ymouse-bow_mc._y;
angle = Math.atan2(ydiff, xdiff);
angle = angle*180/Math.PI;
bow_mc._rotation = angle;
};
// fire arrow at this angle when MB clicked
_root.onMouseDown = function() {
angle = bow_mc._rotation;
angle = angle*Math.PI/180;
++depth;
clipName = "arrow"+depth;
clip = _root.attachMovie("arrow", clipName, depth);
clip._rotation = bow_mc._rotation; // gives the arrow the same orientation as the bow when it is fired)
clip._x = bow_mc._x*Math.cos(angle);
clip._y = bow_mc._y*Math.sin(angle);
clip.xmov = speed*Math.cos(angle);
clip.ymov = speed*Math.sin(angle);
clip.onEnterFrame = function() {
this._x += this.xmov;
this._y += this.ymov;
};
};
Many thanks!! Wishing I'd gone to a few more physics lessons at school now ;¬)
t
View Replies !
View Related
Creating Realistic Flight Of An Arrow
I'm trying to put together some code that will approximate the arced flight of an arrow.
Currently, I've got the code so that the angle of the bow movieclip will move depending upon the position of the mouse. Pressing the mousebutton will then fire an arrow at this angle (albeit at a constant speed). I've played around with xmov and ymov in an attempt to introduce inertia and gravity (respectively) and therefore create a more natural flight of the arrow but aren't really getting what I'm after. Added to this, I also need to alter the angle of the arrow clip over the course of it's flight to imitate the charge in orientation (i.e. starts to point towards the ground in the downward 1/2 of the arc). Code so far is below.
Does anyone have any suggestions? Or even alternatives (such as draw a curve with the curveTo method and then animate the arrow clip along this path? ... LOL, or is this simply wild/hopeful speculation on my part)
speed = 25;
// calculate angle based upon mouse position
_root.onMouseMove = function() {
updateAfterEvent();
xdiff = _root._xmouse-bow_mc._x;
ydiff = _root._ymouse-bow_mc._y;
angle = Math.atan2(ydiff, xdiff);
angle = angle*180/Math.PI;
bow_mc._rotation = angle;
};
// fire arrow at this angle when MB clicked
_root.onMouseDown = function() {
angle = bow_mc._rotation;
angle = angle*Math.PI/180;
++depth;
clipName = "arrow"+depth;
clip = _root.attachMovie("arrow", clipName, depth);
clip._rotation = bow_mc._rotation; // gives the arrow the same orientation as the bow when it is fired)
clip._x = bow_mc._x*Math.cos(angle);
clip._y = bow_mc._y*Math.sin(angle);
clip.xmov = speed*Math.cos(angle);
clip.ymov = speed*Math.sin(angle);
clip.onEnterFrame = function() {
this._x += this.xmov;
this._y += this.ymov;
};
};
Many thanks!! Wishing I'd gone to a few more physics lessons at school now ;¬)
t
View Replies !
View Related
Movement On Curved Trajectory
Hey all,
I'm making a little side-scrolling truck racing game. I want to add bumps and valleys instead of just flat terrain. My only problem is, how do I get the truck to follow the curved line. Sure if I gave the users the ability to control the _y position of the truck then it would work, but then they could choose to fly off the map. I need a way that will enable them to drive UP a curved line as well as DOWN while only holding the right arrow key. Any ideas?
Thanks
View Replies !
View Related
Simple Trajectory Method
Hi guys.
I have a movieclip which i'd like to make travel along based on the coordinates of 2 other movieclips. Let's say the mc I'd like to make travel is called ball_mc.
Now: I 'd like the ball_mc to travel based on the x : y ratio of two other mcs. Pretty standard trig, I'd have thought (and almost likely in the Math class; I just don't know where to look).
The angle between those two mcs becomes the angle I'd like ball_mc to travel along. Also bare in mind that the ball would start at either of those mcs exact location
Basically I need to know the ratio of the 2 mc's x : y so that I can plot my ball's location every few steps - from the 1st mc, up to the 2nd, and beyond (infinity) on the same trajectory. I need to know that angle AND how to calculate the ball_mc's next x and y coordinates based on a step incrementation of my choice.
My maths skills are poor and I don't know how to do it!
I really appreciate any help.
Sean
View Replies !
View Related
I Am Not Able To Achieve The Curve Trajectory
I am not able to achieve the trajectory (from bottom right to left-middle of page in an arc).Also I am not able to get the timing right.Now the animation is happening randomly.But the timing will have to be like this:
Around 5 seconds after the ordinary homepage loads, the bubble will drift onto the screen into the depicted position; hover there for around 10 seconds; and then drift back off-screen.
Any bubble image will do.
Bubble trajectory:
http://www.geocities.com/new_rid123/...trajectory.gif
I am not able to write the code.
I have got something in the form of a js file(bubble.js)
http://www.geocities.com/new_rid123/bubble/bubble.js
http://www.geocities.com/new_rid123/bubble/example.html
but the trajectory is wrong there-it has to be like I have drawn in Bubble trajectory:
Please help me in coding the wiggle effect and the trajectory
View Replies !
View Related
Create Dynamic Trajectory
I have an animation with an airplane that flies on the stage from one end to the other. I have made a curve trajectory using motion tween, but I would like to create a random dynamic trajectory. Any idea how can i do that ? Is is possible to create dynamic motion tween ?
View Replies !
View Related
Trajectory And Firing A Slingshot
Hi folks,
I am almost at the quitting stage with my latest project,
I am trying to build a game where you fire eggs from a catapault/slingshot type device and hits verious random targets.
the effect I want to achieve can be seen at the following link: (just the catapault effect)
http://www.viralmania.com/games/pepsi_bucket/host.asp
So far I have come up with a kind of working version (see attached files) but the trajectory is all wrong as the egg always fires to high and there is no way to simple fire the egg low to the ground (again see the pepsi link above).
I also need the bucket to rotate depending on the direction the catapault is dragged in (though I have a pretty good idea how to do this.)
So can ANYONE please help me with a script thats is very very similiar to the way the catapault in the pepsi game works?
Kind Regards
Drakash
View Replies !
View Related
Simple Tutorial On Trajectory?
I am having trouble making a missle gradually fall down.
Can someone direct me to some simple tuts on that? Or at least tell me what I am looking for. I've found some on gravity, but they are usually about things fall straight down. I found some good things on decay, but nothing that really helped.
I want to shoot something from a cannon and have it eventually start to fall. The few I have found were unnecessarily too difficult.
View Replies !
View Related
Elliptical Trajectory / Motion In As 2.0?
Hey guys, first of all, sorry if this was asked before, i did use the search option first (glanced a bit) and didn't find something related quick so decided to ask:
Does anyone know the correct way for creating an elliptical motion in flash 8? I googled for ellipse equations and stumbled upon these:
http://en.wikipedia.org/wiki/Ellipse
Lower on the page there's also some code (javascript) which generates points that can then be connected to form an ellipse. tried to replicate that in flash, but haven't succeeded. Also, i was wondering if there was another way i could generate an ellipse, which looks more like this http://www.rsc.org/ej/JM/2000/b002092n/b002092n-f4.gif, in the sense that it's "tilted".
I am trying to replicate a sort of solar system, but with elliptical trajectories, and would have liked to have the sun in an upper corner and the planets rotating around it in a sort of "tilted" ellipse.
I also tried to modify the Circular Movement tut also http://www.kirupa.com/developer/mx/circular.htm.
Sorry if the question is dumb or already answered in a previous post. Thanks in advance!
View Replies !
View Related
Ball With Perspective And Trajectory
Hi All
I'm looking for some source or tips on how to make a super simple (ha ha) soccer penalty shoot out type game, where you setup a ball to fire along the Z axis into perspective but with some kinda controllable force and trajectory.
I've seen this before- just can't remember where. Any pointers much appreciated.
Cheers
Sally
View Replies !
View Related
Trajectory In Tile-based Game
ei peeps!
currently making a tile-based game, with a 45 degree angle perspective. I have some enemy movieclips on the board and i want them to throw a granade at any target square on the grid. Of course, granades have to follow a trajectory from start to finish. I know that i can use Math.sin and Math.cos to calculate a path, but i'm stump in trying to figure out, how to calculate the trajectory so that it would hit a target square especially since i'm viewing the grid at an angle.
any help would be very mush appreciated.
View Replies !
View Related
Making Simple Parabola Trajectory
A very simple equation for a parabola could be
y = x^2
How come this works:
onClipEvent(enterFrame){
this._y= Math.pow(this._x,2)-5;
this._x ++;
trace ("Y: "+ this._y + " X:" + this._x);
}
But this doesn't work.....
onClipEvent(enterFrame){
this._y=(this._x)^2;
this._x ++;
trace ("Y: "+ this._y + " X:" + this._x);
}
Using the carrot squares something and ignores negative results?
View Replies !
View Related
Slingshot Trajectory And All That Trig Stuff
Hi folks,
I am almost at the quitting stage with my latest project,
I am trying to build a game where you fire eggs from a catapault/slingshot type device and hits verious random targets.
the effect I want to achieve can be seen at the following link: (just the catapault effect)
http://www.viralmania.com/games/pepsi_bucket/host.asp
So far I have come up with a kind of working version (see attached files) but the trajectory is all wrong as the egg always fires to high and there is no way to simple fire the egg low to the ground (again see the pepsi link above).
I also need the bucket to rotate depending on the direction the catapault is dragged in (though I have a pretty good idea how to do this.)
So can ANYONE please help me with a script thats is very very similiar to the way the catapault in the pepsi game works?
Kind Regards
Drakash
View Replies !
View Related
Making A MovieClip Follow A Trajectory?
The title says exactly what my goal is...
My problem is in both determining the trajectory as well as making the MovieClip follow it.
According to my research (high school physics was a while ago) the following are the mathematical equations for trajectory...
x = velocity * time * cos(angle)
y = velocity * time * sin(angle) - 1/2(9.8 * (time * time))
First of all... if those arent correct please let me know...
Secondly.. how exactly can I translate this into ActionScript code? I know the following...
time = 2((0.0 - velocity) / 9.8) (again please correct errors)
and I know the starting co-ordinates of the MovieClip as well as the ending co-ordinates (the mouse's co-ordinates when clicked)
The questions that remain to me are:
(A) What will the velocity be in ActionScript terms? The movie's frame rate? Or the speed at which I set the MovieClip to move as pixels/frame? Or something else?
(B) What is time in an ActionScript sense?
(C) Where should the ActionScript reside in my movie in order to make the MovieClip follow the path? In an onEnterFrame() function?
(D) Is anyone out there experienced with this sort of problem and can they offer me any insight into solving it?
Cheers.
View Replies !
View Related
Launch Object With Realistic Trajectory
Hi. I want to create a side-scrolling game that essentially has something like a cannon that will launch balls across the screen, in an attempt to hit a target. The user needs to be able to customize the angle and power of the trajectory, and the balls need to fly through the air as though under the influence of gravity..
Anyone know where I should start?
Thanks.
View Replies !
View Related
Making A MovieClip Follow A Trajectory?
The title says exactly what my goal is...
My problem is in both determining the trajectory as well as making the MovieClip follow it.
According to my research (high school physics was a while ago) the following are the mathematical equations for trajectory...
x = velocity * time * cos(angle)
y = velocity * time * sin(angle) - 1/2(9.8 * (time * time))
First of all... if those arent correct please let me know...
Secondly.. how exactly can I translate this into ActionScript code? I know the following...
time = 2((0.0 - velocity) / 9.8) (again please correct errors)
and I know the starting co-ordinates of the MovieClip as well as the ending co-ordinates (the mouse's co-ordinates when clicked)
The questions that remain to me are:
(A) What will the velocity be in ActionScript terms? The movie's frame rate? Or the speed at which I set the MovieClip to move as pixels/frame? Or something else?
(B) What is time in an ActionScript sense?
(C) Where should the ActionScript reside in my movie in order to make the MovieClip follow the path? In an onEnterFrame() function?
(D) Is anyone out there experienced with this sort of problem and can they offer me any insight into solving it?
Cheers.
View Replies !
View Related
|