Gamestudio Links
Zorro Links
Newest Posts
Alternative to Stooq for Zorro S
by cwford. 10/09/26 21:13
Stooq now requires an API key
by cwford. 10/08/26 23:27
ZorroGPT
by TipmyPip. 10/06/26 05:32
Purchase A8 full licence version
by jcl. 10/05/26 12:12
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (Quad, TipmyPip), 18,011 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
JimSimons, julienp, julienper, KelleyAbbey, Yopachi
19246 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