Game Development Community

stopping weapons from going into interiors (visually)

by Trevor "PointDestruction" · in Technical Issues · 08/23/2002 (12:49 am) · 16 replies

Well, i've seen it in games before, and I was wondering how to make it so that when you're in first person, how to stop it from looking like your weapons go into walls and objects en stuff :/

#1
08/23/2002 (1:44 am)
just guessing but can we do something with cameras?
#2
08/23/2002 (1:47 am)
Its not only that... ingame, walk up to a wall, when you think your weapon is in the wall--> goto third person, the weapon sticks trough the player. So... the weapon actually collides with the wall, and it doesn't go trough it, but the player is still able to keep on walking and he walks right trough the weapon. At least that's what's happening in my game (release 1_1_2, weapons exported with milkshape).
#3
08/23/2002 (3:57 am)
Is it possible to increase the collision box on the player to include the space the weapon would be in?
#4
08/23/2002 (4:08 am)
I had a fix on this prior to getting my new computer.

It only required commenting out one line, and replacing it with another... I really wish I made a backup of that version of Torque.

I'll try to look through the code if I have time, because this definately is something that I know I'll need again :p
#5
08/23/2002 (6:24 am)
That'a a pretty easy thing to do., no need to mess around with collision.,
In opengl the solution is just to decrease the depthrange on the zbuffer...,

glDepthRange (0, 0.3);

render first view weapon

glDepthRange (0, 1);

Bruno
#6
08/23/2002 (11:35 am)
No need to do that... torque moves weapons backwards when they touch a wall.... look at the blue rifle in the torque demo app...
#7
08/23/2002 (11:41 am)
Quote:
torque moves weapons backwards when they touch a wall

that's the reason the guns go stick trough the players when they run up to a wall... not a pretty sight.
#8
08/23/2002 (1:17 pm)
wow this got a lot of attention lol

Bruno: Where exactly is that line I change?
#9
08/23/2002 (1:29 pm)
btw I had sorta played with this before and figured out that it actually might be a one line thing, I have no idea where bruno's changes are to occur.

Everyone: I'll agree when the guns are sticking through the gun's holder because of a collision with the wall ...

I was hoping to get this done for only first person view .. i'm now wondering what it would be like to do the same thing not in third person.
#10
08/23/2002 (9:23 pm)
lol it's funny how much popularity something gets while it's in the right column under newest threads :/.

So I guess ... *bump*
#11
08/24/2002 (2:06 am)
Burno I can't find that line anywhere.
#12
08/24/2002 (7:10 am)
Hey dude.., i don't have the Torque engine..,
I was just saying that if Torque is done in Opengl, you can do that to fix the problem of weapons crossing into walls. If it's D3D, i'm sure there is an equivelent command in the D3D Api...

Bruno
#13
08/24/2002 (8:27 pm)
I searched for that word and got a few results, but none I could see first off that had to do with this.
#14
08/25/2002 (12:33 pm)
I can think of a few ways of dealing with this case, from "easiest" to "hardest":

1. Ignore that the weapon is a solid object and let it penetrate walls. The disadvantage here is you could see the weapon poking through on both sides of the wall. Depending on the model, the muzzle point might actually stick through the wall, which basically means you could shoot through them. Optionally, do as Bruno suggested and render the gun so it looks like it isn't poking through the wall, but if I understand correctly that would only be a visual trick.

2. The method used in Torque: allow the weapon to collide, and back itself off from walls if they're encountered. Disadvantage: It can look bad, mainly from the third person.

3. Create a player animation specifically for the case, where the player either holds the gun vertically or pulls it backwards.
#15
08/25/2002 (1:39 pm)
james, the first one was what I had in mind lol. I just wanted to visually make it look likle it's NOT sticking into a wall. Then you can see the weapon more ..
#16
08/25/2002 (2:18 pm)
Okay. Then I offer another fork in the road, at least for Torque. =)

1. Remove the weapon model's collision mesh. Disadvantage: Separate model with a collision mesh in it should be made so that it can be picked up.

2. Disable collision for items mounted on players in the code. Since this is in general, I figured you weren't a licensee... but if you are, comment out the block of code in game/player.cc (Revision 1.20) between lines 3756 and 3772. That should prevent it from moving backwards.

You might be able to do it in script with setCollisionTimeout, but I don't have time to try it out.