Camera keeps going behind walls/floor
Hello, I've recently started my first 3D game in Unity, and I'm currently trying to set the camera, the position and rotation went just fine using some tutorials of talented people, but the camera keeps going through walls or the floor and I can't find any solutions for this problem, so here I am at Unity Answers.
I've already tried casting a Raycast or Linecast between the character and camera, but when it detects an object that isn't the player, it'll just shoot the offset to the minimum, or make the camera have a seizure.
The camera rotates around a pivot, which is the child of the player.
If anyone knows a way to fix this, please let me know.
I look forward to your help!
Answer by AhoKun · Mar 18, 2020 at 09:23 AM
found the solution myself, or atleast something that seems to work, I've sent 6 spherecasts with a radius of .1f into every direction (forward, backwards, left, right, up, down) and make the camera adjust itself to the point where there isn't a solid object in the way anymore.
Your answer
Follow this Question
Related Questions
Third person camera collision problem 0 Answers
Using a second camera and finding it using a tag 0 Answers
How can I make a third person camera collision script? 2 Answers
Why object's doesn't stop on collision enter? 0 Answers
uNet hitboxes and movement. 0 Answers