- Home /
Gun through wall. [please read I don't want layering]
Hi all,
I have a question concerning the fact that my gun goes through the wall. I already tried to do anything to make the gun collide the walls and boxes but it won't do the right physics to stop it from getting through. I would like a total description of how to do this. No layering, Because I want to make a multiplayer fps not a singleplayer one and I don't want it to look like crap which it would with the layering way of doing it.
Thanks, portrius
You have to do layering, it's really not messy or "crappy".
I don't understand what layering has to do with multiplayer. Usually the player is it's own instance in it's own FPS view, and the other players see a 3rd person version of you, so they won't see your gun "layering" on top of the other objects. This is how BF3, CoD, and CS does it. Layering is clean and effective ;)
You could add a box collider to your gun, but like you said, this causes issues with the player physics and that is what you might call "crappy"
if you haven't already looked: http://answers.unity3d.com/questions/41298/fps-gun-clippes-through-walls.html
plus, layering is how those AAA games do objective markers, HUD, e.t.c e.t.c
You would have to give some more info on your gun. Is it made of box colliders or mesh collider?If mesh collider is convex on?
Well, I think it was crappy because when they see a 3rd person view of you they see you with a gun through a wall and that is not realistic to see... And the mesh collider convex didn't work...
Layering is common practice. If you don't want to use layering, use colliders ins$$anonymous$$d, might have to scale up the size though. There's no true way of getting perfect collision in games, I'm sure you've noticed that most games aren't realistic and almost always adopt the mentioned methods. If you find a way that works better please let us know.
Answer by dood_legacy · Jun 10, 2012 at 05:08 AM
Many older games render the weapon in screen space and render it last (on top of all world geometry.) But newer games like BF3, where the player interacts with the world in first person render the weapon in world space, and use some animation overlay to push the gun back.
Just do a raycast along the player's facing direction to get a value back between 0 and 1, and use that to drive the playback of the overlay animation, so as you get closer to walls or objects, the gun's position will move back and not clip through walls.
Your answer
Follow this Question
Related Questions
How do you stop you gun majicaly sinking into walls? 1 Answer
Gun not to make it go through the objects 1 Answer
Sphere through wall - Mini-Golf 5 Answers
Camera looking through objects when touching 1 Answer
Gun reload not working? 1 Answer