Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AemStones, AndrewAMD, gamers, Kingware), 1,679 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 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,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İ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 | 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