Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
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
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 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
Get Velocity? #33801
09/22/04 02:28
09/22/04 02:28
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan


I want to know when a physics object has stopped moving, or very nearly stopped moving so that I can give it a nudge or get rid of it. I looked at phent_getvelocity, but I don't understand the explanation in the manual. How would I use this for what I want?

Re: Get Velocity? [Re: A.Russell] #33802
09/22/04 03:08
09/22/04 03:08
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
my.skill30=1;

phent_getvelocity(my, temp, nullvector);
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)<10)
{
my.skill30+=1;
if(my.skill30>=50)
{
phent_enable(me,0);
break;
}
}


this code would make it check if it is below speed of 10, if yes it's putting 1 + skill30 and if that is above 50 you can do whatever you want with that entity (remove it give a boost w/e you want)

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Get Velocity? [Re: Helghast] #33803
09/22/04 17:56
09/22/04 17:56
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan


Thanks, that looks to be exactly what I'm after. I'll go and try it out.

Re: Get Velocity? [Re: A.Russell] #33804
09/22/04 21:30
09/22/04 21:30
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
This is giving me strange results. This is what I put in my code:

Code:

while (my.z > -1000 && my.s_alive && clear_time == 0)
{


phent_getvelocity(my, temp, nullvector);
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)<10)
{
my.skill30+=1;
if(my.skill30>50)
{
// breakpoint;
my.bright=on;
my.metal=off;
temp.x = 0;
temp.y = -(my.y * 1000); //push up and towards middle of playing field
temp.z = spring_min;

phent_addforcelocal(my,temp,nullvector);
my.skill30=1;
}

}

wait (1);
}



I set the metal flag off and the bright flag on so that I could see balls whose skill30 made it to 50.

Now it looks very funny, because the balls usually get about 2/3 down the screen before popping like corn.

I've tried changing the values on this line:

Code:
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)<10)  



to < 200 and <-2000, but it doesn't make much difference.

I don't understand physics very well, so can someone please explain this? The balls should come to rest/near rest/get stuck for a little time before they pop.



Last edited by A.Russell; 09/22/04 21:33.
Re: Get Velocity? [Re: A.Russell] #33805
09/22/04 22:28
09/22/04 22:28
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
try setting it LOWER, for lower speeds, try putting it to 1.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Get Velocity? [Re: Helghast] #33806
09/22/04 22:30
09/22/04 22:30
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
I tried that. In fact I kept going down 0.1, 0.001, 0, -2000

Not much difference.

Re: Get Velocity? [Re: A.Russell] #33807
09/22/04 22:55
09/22/04 22:55
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
put this before the while:

my.skill30=1;

i dunno if it helps much, but i have it in my script, so see what it does for you:P

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Get Velocity? [Re: Helghast] #33808
09/22/04 23:11
09/22/04 23:11
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan


I have . I've also set skill30 back to 1 after it reaches 50 so that it can get nudged again.

The problem is in the maths. I really don't understand it. From the results of phent_getvelocity how can you know how fast the object is moving?

Re: Get Velocity? [Re: A.Russell] #33809
09/22/04 23:55
09/22/04 23:55
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
do you have msn or icq, i dont want to paste my whole code in here...

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Get Velocity? [Re: Helghast] #33810
09/23/04 01:26
09/23/04 01:26
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Code:
  
while (my.z > -1000 && my.s_alive && clear_time == 0)
{


phent_getvelocity(my, temp, nullvector);
if( vec_length(temp)<10 )
{
my.skill30+=1;
if(my.skill30>50)
{
// breakpoint;
my.bright=on;
my.metal=off;
temp.x = 0;
temp.y = -(my.y * 1000); //push up and towards middle of playing field
temp.z = spring_min;

phent_addforcelocal(my,temp,nullvector);
my.skill30=1;
}

}

wait (1);
}



Try this first. What you are after in that call is if the MAGNITUDE (ie length) of the velocity vector is small.
The following (temp.x*temp.x+temp.y*temp.y+temp.z*temp.z) won't do it.

VecLength is equivalent to SQRT(temp.x*temp.x+temp.y*temp.y+temp.z*temp.z) and that will (or should) work.

Try it out and tell me what happens

Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

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