|
2 registered members (juanex, AndrewAMD),
988
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
ent_remove help.
#297679
11/09/09 09:32
11/09/09 09:32
|
Joined: Apr 2005
Posts: 795 U.S.A. Michigan
exile
OP
User
|
OP
User
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
|
I am currently having a problem with my shooting script. I have looked everywhere and spent the last 3 hours searching the manual but I still couldn't find anything that could help me. For some reason my code doesn't remove the bullet whenever it collides with level geometry. I currently have the passable flag set on which I believe to be the problem. However, I NEED the flag to be on for my game to function properly. So I am asking if there is anything that I can use in a statement to test for block collision? I am not very good at explaining what I mean, so here is an example.
while(vec_dist(my.x,block) > 20)
{
c_move(me, vector(0,60*time,0), nullvector,IGNORE_FLAG2+USE_AABB);
wait(1);
}
ent_remove(me);
snd_play(bullet_hit,100,0);
}
Notice how in the "while(vec_dist(my.x,block)" statement, I used the word block to represent level geometry. Something like this would be most useful and I am sure 3DGS has this feature. I just cant find it.
|
|
|
Re: ent_remove help.
[Re: exile]
#297683
11/09/09 10:00
11/09/09 10:00
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
you can test for hitting blocks several ways... through events (EVENT_BLOCK) or through the return type of a c_trace (then do a tex_name, combined with hit). look that up in the manual, should get you started  regards,
|
|
|
Re: ent_remove help.
[Re: Helghast]
#297750
11/09/09 16:05
11/09/09 16:05
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Im not sure if this will work, but give it a try...
...
var dist=0;
while(1)
{
dist = c_move(me, vector(0,60*time,0), nullvector,IGNORE_ME+IGNORE_FLAG2+USE_AABB);
if((dist!=0)&&(you==NULL)) { break; }
wait(1);
}
ent_remove(me);
snd_play(bullet_hit,100,0);
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: ent_remove help.
[Re: muffel]
#298323
11/13/09 20:33
11/13/09 20:33
|
Joined: Apr 2005
Posts: 795 U.S.A. Michigan
exile
OP
User
|
OP
User
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
|
I have already tried that. Because my player models box is rather large I have to create the bullet model so far out that it looks rather strange. Thanks though  EDIT: Oh and Rei, sadly I currently have the "you" pointer being taken by... you = ent_create("mgun.mdl",my.x,gun_attach);. So I put, "you = player;" in my bullet code. Sadly, my character STILL picks it up. To make this a bit easier, i'll post my gun code.
function pistolbullet()
{
you = player;
my.ENABLE_BLOCK = ON;
my.ENABLE_ENTITY = on;
my.event = collisionhit;
my.passable = off;
my.pan = player.pan + 270;
my.tilt = player.tilt;
my.ambient = 100;
while (1){
c_move(me, vector(0,60*time,0), nullvector,IGNORE_FLAG2+IGNORE_CONTENT+ignore_passable+IGNORE_ME+IGNORE_SPRITES+IGNORE_YOU);
wait (1);
}
}
Last edited by exile; 11/13/09 22:49.
|
|
|
Re: ent_remove help.
[Re: exile]
#298467
11/15/09 11:31
11/15/09 11:31
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Rei's suggestion with 'you = player' and 'IGNORE_YOU' is the common way to avoid collision with the origin of the bullet.
But, if this doesn't work, you could try this: You could create the bullet at a vertex at the gun's end with vec_for_vertex. Then you could reduce the collision box of the player with max_x, min_x, max_y, min_y, that the gun's end is out side that collision box, and the bullet is created outside. You can see the size of the box when hitting F11 twice.
About "you = player" and "you = ent_create": you and me are pointers that are relatively to an entity's function, this means that the 'you' within the function of the player points at a different entity than the 'you' within the bullet's function.
|
|
|
|