Block camera from moving outside X/Y values

Hello,

I’m playing around with the twin-stick shooter tutorial and I noticed that moving towards the edges of the “Arena” makes it possible to look outside of it.
I would like to have the camera be blocked before reaching those positions.

I tried using Camera Block Volumes, but the camera simply goes right on top of the actor.
My idea was to set a blueprint so that if the camera’s Global World Location is outside the ranges I want, to set it’s World Location to my predefined maximums.

I did it, but when I attached the Event on the player movement, I got my camera to stutter back and forth when moving on those “out-of-bounds” locations. I also tried calling it on every tick, which resulted in stutters only when moving back inside acceptable ranges.

Any ideas?

Edit: I couldn’t upload the Blueprint image before.

  • All Blue Lines are references to my Camera
  • ResetCamera should be ResetCameraX and ResetCameraX should be ResetCameraY (typos…)
  • Inside ResetCamera I set relative X to 0, while keeping Y to current relative position.
  • Same applies for ResetCameraX

http://i.imgur.com/RKM1QSJ.jpg

So, I had an idea:
The reason behind the stuttering should be caused by the fact that the World Location and the Relative Location were not set accordingly, so I decided to make the same thing with Relative position, by taking the difference of my main Pawn from my desired coordinates and adjust the camera’s relative coordinates accordingly.

While this worked perfectly for the Y axis, the X axis was a mess, due to the camera’s X axis and the pawn’s X axis not being aligned.
To solve this I added another spring arm parallel to the plain of the pawn, and added the camera on the end of it and rotated it there. After that I simply changed the blueprint to alter the second’s spring arm relative position instead of the camera, and voila.