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
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,359 guests, and 7 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
Guns blazing #134151
06/05/07 23:47
06/05/07 23:47
Joined: Sep 2006
Posts: 148
Ireng Offline OP
Member
Ireng  Offline OP
Member

Joined: Sep 2006
Posts: 148
Hi cute people.
I'm trying to make a gun fall to the floor without using physics. This code is activated when the gun holder dies:

Code:
			vec_set(temp, my.x);
temp.z -= 900; // trace downwards 500 quants below
c_trace (my,temp,IGNORE_ME|IGNORE_MODELS|IGNORE_SPRITES|IGNORE_YOU);
my.push=0;
my.passable=off;
while(vec_dist(me,target)>5)
{
c_move(me,nullvector,vector(0,0,-7*time),ignore_you|ignore_sprites);
if(my.roll<90)||(my.roll>180){my.roll+=10*time;} // rolls while falling
wait(1);
}



But the gun simply rolls 90ยบ, and THEN falls to the floor. It looks very dumb.
Any ideas on how to fix this?
Thanks in advance.


"When the battlefield is under total control, war becomes routine." Old Snake
Re: Guns blazing [Re: Ireng] #134152
06/06/07 03:37
06/06/07 03:37
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
your vec_dist looks wrong. You need to be more specific with the pointers. target is not a pointer, it's just a 3 dimensional vector, so it doesn't need the .x.

vec_dist(my.x, target);

Also, don't use target, as it changes every frame. Store target in a local var[3] before the while loop, and then check with that.

Final code:
Code:

var targ[3];
vec_set(temp, my.x);
temp.z -= 900; // trace downwards 500 quants below
c_trace (my.x, temp, IGNORE_ME|IGNORE_MODELS|IGNORE_SPRITES|IGNORE_YOU);
my.push = 0;
my.passable=off;
while(vec_dist(my.x, targ) > 5)
{
c_move(my, nullvector, vector(0,0,-7*time_step),ignore_you|ignore_sprites);
if (my.roll<90)||(my.roll>180){my.roll+=10*time;} // rolls while falling
wait(1);
}




xXxGuitar511
- Programmer
Re: Guns blazing [Re: xXxGuitar511] #134153
06/06/07 17:26
06/06/07 17:26
Joined: Sep 2006
Posts: 148
Ireng Offline OP
Member
Ireng  Offline OP
Member

Joined: Sep 2006
Posts: 148
Thanks for the clean-up.
Actually, the problem was that I had put two overlapped guns in the same spot, by accidentaly duplicating a part of the code.
Thanks anyway.


"When the battlefield is under total control, war becomes routine." Old Snake

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