Attaching a collision volume to a camera and not to the spring arm

I am working on an RTS/city builder and want my camera to be able to collide with the terrain. Moreover, I want to restrict how far the camera can be moved out and I was planning to this with a blocking volume. This is my setup.

  • A pawn that has a spring arm, a sphere collision and a camera.
  • Moving the camera in game is done by moving the pawn using Add Movement Input
  • The camera is rotated in game by rotating the spring ar, by Add Relative Rotation
  • The zoom function is made by changing the Target Arm Length of the spring arm.

I don’t want my spring arm to handle collision as it will almost never be in the same location as my camera. Hence I have disabled Do Collision Test for the Spring Arm (enabling it gives weird results with the camera jumping around and I believe its useful for 3rd person games but not here). That’s also the reason I added the sphere collision and was hoping for it to collide with the terrain and block the camera. But no such thing is happening.

I also don’t want the camera to move too far out so I was thinking of blocking it with an invisible wall blocking volume. It doesn’t work and the camera goes right through the invisible wall. Here’s a representation of what I am trying to do.

The gizmo is on the player start and the spring arm is long enough to be higher than the central mound. I am attempting to move the camera on the x axis towards the blocking volume and the camera goes right through it.

I think I didn’t setup my collision presets right. So here is what I have setup. This is the preset for the blocking volume
image
And this is the preset for the sphere collision inside the pawn
image

What am I doing wrong here?

EDIT: I just learnt that in order for a pawn to undergo collision, the collision component must be the root. But this is problematic as if I make the collision component the root, then the collision happens at the spring arm location and not at the camera location. That is why I ordered the pawn as Spring arm → sphere collider → camera so that the collider stays with the camera.

So what you’re doing here with the camera boom- clamps are going to be your friend.

What many do is: Since your pawn is flight-based, do

Collision as root.

springarm.

Camera.

Set the springarm to a length that if you were to sit the collision on the ground, your camera will be at the lowest point you want it. For instance, if you would want “person” level, make the springarm 300 units (3ft) in length. So when you go to the ground, the collision stops your camera at an appropriate spot.

Now here’s the kicker- change out all the springarm movements to be the root (collision sphere) instead! Mouse wheel- make it affect actor Z, not springarm length. Spin left and right? Actor rotation. I do recommend the “Do Collision Test” because that will make the springarm react and shorten if you are backed against something (like a building) and keep your camera from phasing through things.

Give this a shot and let us know how it goes!

1 Like

Hey @SilentGarud, just checking in with you!
Did that end up working out for you?

Let us know for future answer seekers! :slight_smile:

Ah, sorry about that, I have been unwell. But yes, it did work. Thank you for being patient and helping. Much appreciate it!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.