Camera Collision against Walls


author: Ali Abunada

The last thing you want to see in a game is a cheater; unless it's yourself of course. Working on this first sprint from scratch as a blank project meant I had to relearn the fundamentals of Unreal. It sounded simple, but of course I had my grievances with one of the most important things of gameplay--the camera. The player's camera, to be specific. After setting the camera on a spring arm, I started to walk around and noticed that the camera was clipping into one of the walls I placed into the level. This could be bad for the players playing the game as it could obstruct their view when unnecessary space they should be using to view enemies.

So the issue was obvious; I had to make sure the camera didn't clip into things. If it could clip through a simple square resized to look like a wall, it could definitely clip through other assets in our game. I thought that this was an issue with the camera, so I fiddled around with its blueprint settings for a while trying to get it to work. Assuming maybe I could use some sort of collider, I found that was quickly going to be an issue as I didn't want the camera not clipping into every object. Surprisingly, I found that the thing I was looking for was in the Spring Arm. So adjusting its target length, position, and finding something called 'Do Collision Tests' I was able to make sure that it didn't clip through anything I didn't want it to.

Leave a comment

Log in with itch.io to leave a comment.