Collision with camera should not "iritate" AI

I want to set up my small 3rd person project in a way that AI characters can walk between the camera and my player character. So I’ve change the collision settings for the spring arm to ignore pawns. This works fine but now my camera can clip into the AI characters. I’ve been trying to solve this by adding a collision sphere around my camera that is set to block pawns.

This solves the clipping problem, but also “irritates” my AI characters so they try to get out of the way when they collide with the camera. Is there a way to set up the collision so that it’s always the camera that is pushed to the side/blocked and the AI characters are unaffected?

Or am I on the complete wrong track and there is a different, better way to reach my goal of a camera that can’t go into characters but allows them to move between camera and player?

haven’t done this myself, but I think it should work:

Project settings> Collission > make a new object channel

apply that to your spring arms collision details
image

on the AI actors, setup custom collision and handle the new channel

1 Like

Thank you for your answer, unfortunately this doesn’t work for me. If I set it up like this in the ThirdPersonStarterGame the camera isn’t blocked by Actors anymore and can clip inside those actors or through the floor


Hey @Gedinixan. I believe you need to write custom behavior for your camera to behave the way you want. Maybe, instead of the solid collision you put on your camera, you should use a TriggerVolume instead. That way, you can create a custom camera class that inherits from ACameraActor and there, you can implement a function to move the camera back if there is an enemy inside the trigger volume or move closer if moving back is not possible.

Hope this helps

Hi there,

You’re trying to achieve an unusual setup. Camera collision can be as complex as you want. Blocking collision spheres don’t work well with collsion capsule “pawn”. So, try to replace the sphere collision around the camera by an invisible static mesh with world static collision. It will behave as a wall.

Hey @kribbeck, thanks for your input. This seems to get a lot more complicated than I expected :slight_smile: With “TriggerVolume” you mean just a standard box collision and than handling the “On Begin Overlap”-Event, right?
I tried this but hit another problem. Collisions seem only to be checked while my character is moving. So if I walk my character in a way that the camera ends up in another actor the Event is triggered. But if I use the mouse to move the camera around the collision is not triggered. Any idea how I could get around this?

@L.F.A I tried your solution as well, but it didn’t work. With a invisible static mesh I now can move the other actors around by “pushing” them with the camera.

Yeah, just a collision where you set the collision preset to overlap instead of block. So that actors can go through the collision but trigger the OnBeginOverlap and OnEndOverlap events.

Hmm, sounds like the collision is not moving correctly with the camera when you rotate your mouse for some reason. Is the component assigned as a child of the root component inside the camera actor?

Hi there,

It seems that the sphere is applying impulse on hit.
Try to set collision preset as Query Only (no physics collisions).

First let my say I really do appreciate that both of you take the time to help me! Thanks!

@kribbeck Yes, I think so - here is how I set it up:
Screenshot 2022-07-27 231807
Screenshot 2022-07-27 231825

Edit: The collision box moving doesn’t seem to be the problem. As a test I added a tiny visible cube-mesh as a child to the collision box. This cube always stays perfectly in place in the middle of the picture while moving the mouse. So I’m positive that the collision box is also moving with the camera as it is supposed to.

@L.F.A I changed it to Query only but it doesn’t seem to change anything. The other actor is still pushed around, but a little less than before. Also this solution seems to have the same problem as kribbeck’s - If I don’t move my character but only move the mouse no collision is triggered and I still end up with the camera inside the character.

To finish this: I’ve now solved it by doing a sphere trace at my camera position every tick and hiding all actors that get hit by this trace. It feels pretty clumsy but I couldn’t find any information on the collision behavior of the camera while moving it around. If anybody in the future comes up with a better solution, please share it!