I need to simulate (or employ somehow) something that Pawn (if I understand correctly) class does out of the box. I am moving camera from code, using
Obviously, it moves through everything, but I want it to stop entering into guts of my meshes. Meshes have collision meshes set up. But whatever I do with camera - nothing helps.
On top, stepping into AddActorLocalOffset, tracking the ‘bSweep’ flag (the ‘true’ argument above), yielded me this line:
I.e. it ignores the sweep argument.
What I am doing wrong here? What are correct steps to move camera with collision enabled.
You need a Spring Arm Component, which traces against the ‘Camera’ channel and moves the socket along the arm. See USpringArmComponent
Whatever is ‘Owned’ by the Spring Arm will be ignored, so you can’t stop it going inside the mesh (which you wouldn’t want to do anyway, if you’re backed up against a wall it wouldn’t know what to do) - but it will stop it going inside other objects etc.
Interesting, I did couple of experiments and it seems if you create a CameraActor - this stuff cannot be blocked by anything whatever you do. The root SceneComponent ignores bSweep argument.
I created camera as in provided link, but I did simpler, without USpringArmComponent - just created sphere, disabled sphere rendering. And then added camera component to it.
And it started to collide, awesome result I believe. It travels along collision borders as I desired.
Now another question.
My camera is actually flying inside cloud of moving objects. So camera now does not fly into objects. But if an object flies over the camera, then camera gets into objects mesh and actually gets stuck in there. I cannot block objects movement in this case - it will only need to push camera from it’s way somehow.