Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,346 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Detecting entity velocity? #150268
08/26/07 07:31
08/26/07 07:31
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
Simple situation. Pressing space bar adds velocity to an entity using phent_addvelcentral(). The question is, how do I do this based on the condition that there isn't allready velocity along the same axis?

phent_addvelcentral(my_entity,vector(0,0,key_space * 10));

This will make the object "my_entity" move upwards as long as the space bar is held. What I want is for it to only add the velocity if there is no movement along the Z axis allready. In other words, it should make the object "jump" but not fly.

Re: Detecting entity velocity? [Re: jfizer] #150269
08/26/07 07:43
08/26/07 07:43
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
You could call phent_getvelocity, or else compare the z position between two frames:

var z1 = my_entity.z;
wait(1);
var z2 = my_entity.z;
if (z2 != z1) ....

Re: Detecting entity velocity? [Re: Spirit] #150270
08/26/07 07:53
08/26/07 07:53
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
Having a bit of teething problems with phent_getvelocity().


phent_getvelocity(my_entity,temp,nullvector);
if (temp.z == 0)
{
phent_addvelcentral(my_entity,vector(0,0,key_space * 10));
}


Does nothing. So I guess I'm not sure what value to be looking for.

Re: Detecting entity velocity? [Re: jfizer] #150271
08/26/07 07:58
08/26/07 07:58
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
Put a watch on the velocity vector and it seems to be 0.000 +/- 0.5, makes it kinda fun to detect a rest state...

Re: Detecting entity velocity? [Re: jfizer] #150272
08/26/07 08:07
08/26/07 08:07
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
Even more fun, phent_getvelocity() detects if the object is moving up a ramp as velocity along the Z axis. So this just flat out wont work. How very frustrating.

Re: Detecting entity velocity? [Re: jfizer] #150273
08/26/07 08:43
08/26/07 08:43
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Welcome to world of programming my friend!

Well I think you could solve the easy problem of small z movements yourself, but it seems you dont want to detect a z velocity at all! Maybe, you want to detect something like if the entity has ground contact or not?

When programming its good to make up your mind beforehand as precisely as possible what you need and want, cos otherwise you waste time by trying other solutions only to find out that this wasnt what you wanted after all.

Re: Detecting entity velocity? [Re: Spirit] #150274
08/26/07 09:10
08/26/07 09:10
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
Yea, thats what I'm working on now. Casting out a ray to detect ground. My hope was that phent_getvelocity() was relitive to the object and not the environment.

My goal here is to do everything with the physics engine rather then animate movment. So all controlls are going to be an exertion of force on the player entity. Basic movement was easy, but jumping seems to be a problem.

At any rate, I think its time to sleep. Things will make more sense in the morning.


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

Gamestudio download | 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