Collision on a 3rd Person Camera
A little while ago it was my task to create a Third-Person-Controller. I have not really gotten into it myself at the time, but I wanted to do it properly. And I have quickly realized that the camera is gonna be the part I'll work on the most. The movement itself was not too difficult.
Getting the camera to not clip through walls was difficult. Especially because I wanted the camera to "understand" when it has to go in front of an object and when not (for example a pole is allowed to be between camera and player.)
The first thing I have tried is shooting a RayCast from the CameraCenter to the Camera. If it hits anything before the camera, the camera will get set to the hitpoint.
Unfortunately half of the near clipping plane will go through the wall, because it will only check the exact middle point of the camera.
It took quite some time, but eventually I came up with checking the four corner points the way you see it in the gif below. The shortest is highlighted in blue. Except if there is no shortest. Then all points are considered the "shortest".
About Me
Finished studying Game Design at the UE/BTK Berlin with focus on Programming. Currently working at the FHV in Austria as Scientific Project Staff (But really a Unity Developer).
Skillset
- C# / Unity
- AR / MR / VR
- Git / Bitbucket / SourceTree
- Basic Shader Coding
- Basic HTML, CSS and JS
Currently getting into
- C++
- More advanced Shader Coding
Links
- Itch.io
- CV
nino.brugger@gmx.at