Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,507 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 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 | 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