You are not logged in.
Pages: 1
Hi everyone, another problem I have been trying to solve but since I havent had a math class since like 4 years I really suck at looking for derivatives and such. What I wanna do is make the player jump like a frog (parabolla trajectory). So when he clicks somewhere, I would like to know the angle he needs with the given speed, and gravity to travel to where the player clicked.
Here is what I tried (taken from wikipedia: http://en.wikipedia.org/wiki/Trajectory)
speed = 10;
gravity = 0.5;
xDestination = 100+random(400);
tDist = xDestination - x;
direction = arcsin(gravity*tDist/sqr(speed)) / 2;
It should also take into account the maximum angle in case the speed is not enough high. Also, I would potentially like to have a piece a script that gives me the required speed AND direction in order to travel to where the player clicked.
Thank you,
Miguel
Offline
Also, I would potentially like to have a piece a script that gives me the required speed AND direction in order to travel to where the player clicked.
I believe, without constraining the outcome in some other way, there will be an infinite number of solutions for two unknown variables.
If you want the solution for only one variable, given the other, there are at most two solutions.
This is a topic that comes up every few months at the GMC. Yourself, Tepi, torigara, icuurd12b42, and some others have worked out solutions. Yourself, in fact, has an example on his web site that demonstrates it. See Trajectory Aiming at the bottom of this page.
http://gm.ultimatepronoun.com/index.php?page=Examples
Some discussion about various solutions can be found here:
http://gmc.yoyogames.com/index.php?showtopic=421364
http://gmc.yoyogames.com/index.php?showtopic=441584
http://gmc.yoyogames.com/index.php?showtopic=478624
Abusing forum power since 1986.
Offline
Pages: 1