The question is answered, right answer was accepted. Also a duplicate
How to make a object collide with the camera?
Ok, i am with a VERY VERY BORING problem here. I am making a FPS and obviously my character have a gun. The probelm is that when i reach in walls,trees,etc the gun pass trough them.
It also happens with the camera. When i reload my weapon it pass trought the camera. I already tried to put a camera in the weapon,make a new layer and all,put a collider but it doesn't work!!
If you didn't understand, just look at the picture. That's my problem .-.
It's a comment problem and you will find many threads about it. There are several solutions. The two most popular are: 1. Render the weapons by a second camera which has a different depth than the main one, and render nothing else (no walls etc.) with it 2. $$anonymous$$ake the viewmodel weapon very small so it fits inside the character's collider (which needs a RigidBody of course). With the right positioning there won't be any difference from the player's perspective.
As for the camera going through walls, check Camera.nearClipPlane
What doesn't work / in what way does it not work, and why do you think it didn't?
"It didn't work" is not helpful.
It's also possible that parts of your animated mesh actually go behind the camera during an animation, in which case you have to move the objects further forward or change the animation.
Answer by Flaring-Afro · May 03, 2016 at 05:47 PM
Try following this tutorial. Hope it helps.
After trying several times, It worked by creating 3 cameras. (Do not ask me how I did it) BUT what matters is that it's working!
I realized I had to create and configure some things and edit each layer in half the video. Thank you! ^.^
Answer by coolraiman · May 03, 2016 at 05:39 PM
have you tried rigidbody with a collider? also try to lower the near value in the camera properties. the near limit at how close object should be drawn
Follow this Question
Related Questions
2d box collider not working (have rigid body) 0 Answers
Move the Main Camera on Collision 2D 1 Answer
How can I make a third person camera collision script? 2 Answers
Camera Following [2D] 2 Answers