Results 1 to 13 of 13
-
March 19th, 2008, 08:57 AM #155Registered User
postsNon linear or parabolic trajectory for airplane
Hey I am not sure if this is the right place to post this question but I thought I would give it a go.
I am working on a paper airplane game that currently just uses some basic physics that would represent a projectile thrown with a certain velocity at a certain angle.
The problem with this is that the model plane acts more like a bullet projectile then a paper airplane. I have found a few websites that talk about paper airplane aerodynamics however I don't know how I could really use them realistically in flash.
http://www.princeton.edu/~stengel/PaperPlane.html
http://www.paperplane.org/Aerodynamics/paero.htm
I also saw this website that utilized loops, and that would be my ultimate goal in the end, however I dont even know where to start and see the math behind that.
http://www.workman.com/etcetera/games/fliersclub/
If any of you know of any tutorials that might explain close to what I am talking about, then that would be awsome! I have a pretty decent understanding of Actionscript so I can most likely work with anything you wish to share.
Thanks for all your help in advance!
-
March 19th, 2008, 02:20 PM #2557Block user.
postsHow realistic do you want it to be?
you = function(){
setEnabled( true );
live();
setEnabled( false );
}
-
March 19th, 2008, 05:51 PM #355Registered User
postsWell ideally I would like it close to what is being achieved in that flight sim, but I am sure there were some major calculations put into it to achieve those moves. Right now my plane's trajectory is that of a canon ball.
-
March 19th, 2008, 07:52 PM #4557Block user.
postsDoes your model take on an angular velocity? The plane in that sim is always moving forward, but at a certain angle (which you would use to dertermine it's rotation). In the example you showed, the angle is affected by "elevator". Notice if you set "elevator" to 0, it more or less behaves like a missile. So you just need to have the elevator variable affect your angle variable every frame.
you = function(){
setEnabled( true );
live();
setEnabled( false );
}
-
March 20th, 2008, 09:40 AM #555Registered User
posts
-
March 20th, 2008, 07:05 PM #655Registered User
postsHere is a snippet of the code. This is a version of the source from electrotank. I will continue to play around with this and see if I can come up with something, but if anyone cares to have a stab at it, go for itCode:function updatePosition():Void { var time:Number = getTimer() - startingTime; positionX = startingX + (velocityX * time); positionY = startingY + (velocityY * time) - (0.5 * gravity * time * time); projectileAngle = Math.atan2(positionY - previousY, positionX - previousX); previousX = positionX; previousY = positionY; } function renderProjectile():Void { projectile._x = Math.floor(positionX * scaleRatio); projectile._y = Math.floor(positionY * scaleRatio); projectile._rotation = radiansToDegrees(projectileAngle); if(projectile._x > Stage.width || projectile._y > Stage.height) { endAnimation(); } }
-
March 23rd, 2008, 06:54 PM #7
does this help to get you going
Code:// think xthrust as general thrust var xthrust:Number; // think of ythrust as the angle input var ythrust:Number; // think of drag as your elevators; var drag:Number; var planeAngle:Number; var positionY:Number; var previousY:Number; var positionX:Number; var previousX:Number; var startX = plane_mc._x; var startY = plane_mc._y; var startRotation = plane_mc._rotation; reset_mc.onRelease = function() { delete plane_mc.onEnterFrame; plane_mc._x = startX; plane_mc._y = startY; plane_mc._rotation = startRotation; }; start_mc.onRelease = function() { xthrust = Number(thrust_txt.text); ythrust = Number(angle_txt.text); drag = Number(drag_txt.text); plane_mc.onEnterFrame = function() { positionY = plane_mc._y; positionX = plane_mc._x; this._x += xthrust; this._y -= ythrust; ythrust -= drag; var planeDY = positionY-previousY; var planeDX = positionX-previousX; var radians = Math.atan2(planeDY, planeDX); this._rotation = radians*180/Math.PI; previousX = positionX; previousY = positionY; this._rotation; if (this.hitArea_mc.hitTest(ground_mc)) { delete plane_mc.onEnterFrame; this._y = ground_mc._y; } }; planeAngle = Math.atan2(positionY-previousY, positionX-previousX); previousX = positionX; };
-
March 24th, 2008, 11:35 AM #855Registered User
postsHey this looks great although I can't get it to loop with your fla, but I will tinker around with this and see what turns up.
Thanks for all your help!
-
March 25th, 2008, 07:14 AM #955Registered User
postsHey I have been doing some more looking around and found this.
http://www.iwr.uni-heidelberg.de/~Mo.../kitedocu.html
This might be useful as well. I will take a look and see if I can implement some of this code into my project.
-
March 28th, 2008, 07:19 AM #1055Registered User
postsAlright well I have an update. I was able to get loops, however it is perpetual, and I have no clue how I would go about so that it would level off based on xthrust1.
I am sorry if the code is messy, I just wanted to get it somewhat working to boost my moral.
Here is the function. Anyway to make it behave a little more like that flight sim?
Thanks for your help
btw: This is based off of neilmmm's code with the provided fla. You did get me in the right directionstart_mc.onRelease=function()
{
xthrust1=Number(thrust_txt.text);
sinx = 0;
ythrust1=Number(angle_txt.text);
drag=Number(drag_txt.text);
drag1=0;
plane_mc.onEnterFrame = function()
{
positionY = plane_mc._y;
positionX = plane_mc._x;
this._x += .1 *(xthrust + xthrust1);
this._y -= .1 *(ythrust + ythrust1) - ((drag * drag) /500);
ythrust = drag2;
xthrust = drag1;
drag2 = -1 * drag * Math.cos(sinx * 180 / Math.PI);
drag1 = -1 * drag * Math.cos(90 + sinx * 180 / Math.PI);
//drag = drag - 1/10;
sinx = 1/1000 + sinx;
var planeDY = positionY-previousY;
var planeDX = positionX-previousX;
var radians = Math.atan2(planeDY, planeDX);
this._rotation = radians*180/Math.PI;
previousX = positionX;
previousY = positionY;
this._rotation;
if (this.hitArea_mc.hitTest(ground_mc))
{
delete plane_mc.onEnterFrame;
this._y=ground_mc._y;
};
};
}
Last edited by Neoge; March 28th, 2008 at 07:24 AM.
-
March 30th, 2008, 07:23 AM #1155Registered User
postsany ideas on how to make it a little less perpetual? would it be handy to post the fla?
-
March 30th, 2008, 07:39 AM #1255Registered User
postsIll just post it...
-
April 2nd, 2008, 08:58 PM #1355Registered User
postsany takers?

Reply With Quote


Bookmarks