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
0 registered members (), 16,232 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
Gravity without physics #291523
09/25/09 22:17
09/25/09 22:17
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
I want to make a vehicle drive on the terrain with hills. Here's the code which I use to place the vehicle on the ground:
Quote:

var trace_to_ground;
action move(){
...
trace_to_ground = c_trace(my.x, vector(my.x,my.y,my.z-1000), IGNORE_ME|IGNORE_PASSENTS|IGNORE_PASSABLE|IGNORE_SPRITES|USE_BOX);
if(trace_to_ground>1){my.z = -275;}
...

But this code does not keep the vehicle on the surface.... vehicle appears on the ground but if I want to drive it down the hill it starts floating in the air, since the hill went down.... Then I decided to pace this code into a loop, so I added while(1)...wait(1), but now the same , the vehicle keeps moving along z=my.z - 275; and even goes through terrain if the hill goes up. I understand why it happens..... I wanted to apply physics but I had problems with scripting it... So, is it possible to keep the vehicle on the ground, no matter what terrain looks like, whether it has hills/mountains/plains/etc, without using physics?


a generator of dull questions smile
Re: Gravity without physics [Re: BastovBros] #291524
09/25/09 22:24
09/25/09 22:24
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
if(trace_to_ground>1){my.z = -275;}

means if distance to ground is more than 1 move me to z-275.

so your distance is always moar than 1 and you always keep moving on -275

that line should be replaced with

if(trace_hit)vec_set(my.x,target);

//target and trace_hit is predefined

Last edited by Quadraxas; 09/25/09 22:27.

3333333333

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