FPS: I don't want my gun to go through walls! Help!

Ok, so for my first person shooter - I don’t want my gun to go through walls (if the character gets really close for example)
Also - I don’t just want to put my gun in a different scene and use sceneOverlay (since this would give the effect that my gun is there and won’t go through walls). I don’t want to use sceneOverlay because then the light sources won’t give the realistic shadows I want on my gun.

Any one out there know how to make my gun overlayed everything in the same scene so it doesn’t render it going through walls but can be effected by light sources?

Thank you for reading! And please help out!

Keep the gun inside the player’s collision box. You can’t make the gun an overlay as well as being in the same scene. Just doesn’t work that way.

Yes, I thought of that - but if the gun is a sniper rifle for say, the tip will go through objects, like walls/boxes… most modern games have a secret way around this - the light effects the objects but the guns don’t go through walls - how are they doing this?

Try setting the gun to xray, then it will be visible no matter what it goes through.

I don’t think the ‘XRay’ button works in the BGE. If it does, that’s a pleasant surprise. Well, you could… Perhaps size the gun down and pull it in towards the camera, so that it still is affected by the lights, but it stays in front of everything? That’s the only thing I could think of… It would be nice, though, if there was some way to get the lighting from another object (i.e. a dummy object in the game scene) and apply it to another object (i.e. your gun in the overlay scene).

@SolarLune: That would be nice…and what is this x-ray?

I seem to remember having x-ray work in a previous project. It’s worth a try anyway. Go to the object display options and check the box that says x-ray.

Welp - I confirm that x-ray does NOT work… unfortunately - because that’s EXACTLY what I need to get this to work. Why doesn’t x-ray work anyhow? They should make that good stuff work!

Have you tried copying all your lights into your overlay scene to mimic the real map?

That’s a shame, I hope it’s implemented later. I guess you just have to ensure it’s inside the player bounds by scaling it down, and moving it closer to the camera like SolarLune said.

Have you tried keeping the gun a dynamic object and parent it as a compound to the player? In other hand you could have a ray sensor so that when the player is too close and facing a wall an animation is played so the player lifts the gun!

Oh, yeah. That is how a lot of FPS games do it. I’d go with torakunsama’s idea.

Hmm - this actually seems like a good idea…