Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Newbie Questions
by AndrewAMD. 12/04/23 11:14
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (TipmyPip, izorro), 556 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Moving on a parable #144735
07/31/07 20:25
07/31/07 20:25
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline OP

Dichotomic
Captain_Kiyaku  Offline OP

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Hi,

i have a small problem to calculate a parable movement.

I want the play (A in my picture) to jump to vector B. While doing it, he has to arrive the height C.




I first scan the bottom infront of the play (100 quants) and calculate the height of the new position.

My problem is to create this parable and how to move the player on it.

Can anyone help me or gimme some hints there?


Thanks in advance!


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: Moving on a parable [Re: Captain_Kiyaku] #144736
07/31/07 20:58
07/31/07 20:58
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
For duration of the curve to apex, increase z value incremently then decrease after apex as one approach to the prob.
e.g.
while (my.z < 50) //apex
{
movement_speed.x = 10;//direction
if (my.z < 50)
{
movement_speed.z += 0.1 * time_step;//incremental climb
}
else
{
movement_speed.z -= 0.1 * time_step;//incremental descent
}
wait (1);
}

Re: Moving on a parable [Re: Nems] #144737
07/31/07 21:07
07/31/07 21:07
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline OP

Dichotomic
Captain_Kiyaku  Offline OP

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
The problem is, i want to pass the C-Position and end on B (exact on it). So if i just increase the movement speed, it won't be correct.


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: Moving on a parable [Re: Captain_Kiyaku] #144738
07/31/07 21:29
07/31/07 21:29
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Do you really need a parable for the movement?
With a circle you can use just simple trig..

Re: Moving on a parable [Re: demiGod] #144739
08/01/07 06:01
08/01/07 06:01
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline OP

Dichotomic
Captain_Kiyaku  Offline OP

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
well i have to pass this C position so i dont think a circle can help here.


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: Moving on a parable [Re: demiGod] #144740
08/01/07 06:19
08/01/07 06:19
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
vertical velocity at any point on the parabola, v = u + at (where "u" is initial vertical velocity, "a" is acceleration [in this case gravity] and "t" is time).

integrating this to find dispacement gives:

z = ut + 0.5att;

if we start at the top of the parabola (to simplify the equation)

-z = 0.5att; (no initial vertical velocity)
tt = -2z/a;
t = sqrt(-2z/a);

now, -z/a is positive because a is negative (gravity). if we treat gravity as positive, then z has to be positive because the axes need to be in the same direction:
t = sqrt(2z/a);

now we know the time to reach the top of the parabola.
v = u - at; (we're treating a as positive; we can either do "u - at" or "-u + at" because v has to decrease with time)
u = v + at; (we know v = 0, and we know a and t)
u = at;

now for the lateral initial velocity (let w = lateral velocity because v has already been used):
w = d/(2t); (velocity = distance / time)
there is no acceleration involved, because gravity is perpendicular to w. we doubled t because t is the time to reach the top of the parabola, and it takes the same time to come back down.
d is the distance from A to B in your diagram.

initial velocity is w + u.

in code:
Code:

var t; // time
var a; // gravity. set to a positive value
var z; // the height you want to jump to
VECTOR d; // this is the vector from A to B in your pic
var u; // initial vertical velocity
VECTOR w; // initial lateral velocity
VECTOR speed; // i don't know what vector you are using for your player's speed, but this represents it for this example.

...

// set a to positive gravity, z to the height of C in your pic, and d to the
// vector from point A to B, then the following should calculate the required velocity:

t = sqrt(2*z/a);
u = a*t;
t = 1/(2*t);
vec_set(w,d);
vec_normalize(w,t);
vec_set(speed,w);
speed.z = u;


feel free not to declare most of those variables and use constants instead (and substitute into the code at the end).

i'm pretty sure this would work.

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Moving on a parable [Re: JibbSmart] #144741
08/01/07 07:51
08/01/07 07:51
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline OP

Dichotomic
Captain_Kiyaku  Offline OP

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
First, thanks a lot for your help and your very good description.

Second, i'm not able to get it to work.

Somehow speed.z is always "10" and doesn't change at all.
I calculated the vector d with

vec_set(d, vNewPos);
vec_sub(d, my.x);

If this is wrong, please tell me. Then i use your calculations in a while loop so i can move along it, but it only moves upwards.
I'm not sure if i have to refresh the vector d in the loop, but i tried it too.


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: Moving on a parable [Re: Captain_Kiyaku] #144742
08/01/07 09:51
08/01/07 09:51
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
this is correct sorry, i didn't explain the implementation well enough. my code will calculate the strength of the jump for you -- do it once when you want to start the jump. use "accelerate(speed.z,-a,0);" every frame to handle downwards acceleration due to gravity (this makes it a parabola) and store actual movements in a separate VECTOR which you can edit according to time:
Code:

VECTOR moveSpeed;

...

vec_set(moveSpeed,speed); // do this just before your c_move, and use moveSpeed instead of speed
vec_scale(moveSpeed,time_step);



i hope this works
if it doesn't it could just as likely be my fault as yours. i can't see any fault in my calculations, but i'm still worried there is. questions in my school's physics and maths usually have different givens and different unknowns.

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Moving on a parable [Re: JibbSmart] #144743
08/01/07 10:39
08/01/07 10:39
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline OP

Dichotomic
Captain_Kiyaku  Offline OP

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
this looks more like a parabel now

Though there is one problem left:

When i jump, i touch the height of C. But i don't know how i get the horizontal speed to reach the x-position of C when im at the Y-Position.

i thought w will do this but it just jumps up and down, without moving forward at all.


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: Moving on a parable [Re: Captain_Kiyaku] #144744
08/01/07 11:04
08/01/07 11:04
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Code:

t = sqrt(2*z/a);
u = a*t;
t = 1/(2*t);
vec_set(w,d);
vec_normalize(w,t); // this sets the horizontal jump speed
vec_set(speed,w);
speed.z = u;

i was pretty sure this would set the correct horizontal speed.
your code:Code:
vec_set(d, vNewPos);
vec_sub(d, my.x);

i would've thought this would set it right. are you sure vNewPos is the right place?

i'm not sure what could be wrong with the horizontal motion. are you saying that it reaches the y-position but not the x-position?

julz


Formerly known as JulzMighty.
I made KarBOOM!
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1