How to constantly move one actor smoothly

Hi.
So this is the scenario:

I have two actors(player characters) that are constantly moving in random diretions and a camera that simply finds the center of both players and set itself in that location

but sometimes the players teleport to other locations and that changes instantatly the center of both characters wich means the camera too, and that just looks bad.

How can i make the camera follow the center of both characters smoothly.

You can use Camera Boom ([Spring Arm Component][1]) to have nice smooth camera location transitions.

In the component enable the camera lag and set it to desired value (lower == slower):

262137-ah12.png

When having the camera on your character (you can see the UE example TopDown or ThirdPerson templates to see how it’s added there) you can use it like that, e.g. in EventTick or in some timer:

Then the camera will follow the middle point smoothly, even in case of player teleport.
I’ve tested it, here is how it looks like, with sudden player teleport included:

[(Smoother version)][5]

You can also use the SpringArmComponent Target Arm Length to add some zoom in/out depending on your Player1 <—> Player2 distance.

lag shure did the camera move smoothly but this still hapens

262191-2.gif

i’ve also tried to lower the sepeed but nothing.

ps: it’s a 2d game with no prespective so the zoom has to be the camera’s ortho width.

What happens exactly? Both pawns are teleported in that gif?
I’ve just tested it on my end and when both pawns are teleported (SetActorLocation), then the camera goes smoothly to their new location, so I’m not sure what happens with your pawns.

basicaly the red sphere is the moving pawn atacking the other. and when the other dies he spawns in the center of the map, in front of the yellow square. sorry for this gif.

If it dies and spawns back, then maybe the OtherPawn reference is invalid for that time. Can be checked by IsValid node.

Also, if the SpringArmComponent is attached to the pawn that dies, then it will reset like that, since it destroys the actor and spawns it back.

So if your player is destroyed and spawned back, then probably a separate actor will be needed for camera. So the camera with SpringArm is not inside your player blueprint and it won’t be destroyed as well. Worth trying.

The player pawn is never destroyed it just changes a few variables (ex:animation) and teleports to the center of the map (setActorLocation).
And the camera is already a seperated actor.

Well, I don’t know how your blueprint logic is built there, but something must interfere with the camera or Spring Arm Component. As you can see on my gif, it works properly when being used on other actors. To narrow down the issue you can e.g. test it on other actor - e.g. tell the camera actor to follow some other actors (not your pawn class), and also make these actors snap to the map center. If that will work ok, then you’ll know that there is something wrong inside your pawn class.

Colatran, I know you mentioned that your camera is a separate actor… but in your GIF… from the way it moves, it really looks like it is a component of one character, or its position is closely linked to ONE character

i’ve tryed with other actor still the same:

262370-3.gif

can you send me the blueprint of your camera?

the camera gets all ators of class of the player character and saves them in an array.
sorry for the bad gif

It’s the screenshot here, nothing more. It’s placed inside the UE Third Person template character in EventTick, using the already placed CameraBoom there. The OtherPawn is saved once, by GetAllACtorsOfClass() and picking the first one from the array, on BeginPlay. Maybe you can test it on your own, on the same setup (Third Person Character template) so you can see why this works and your setup don’t.

I found the issue, there’s nothing wrong with the blueprints, just had to disable “do collision test”:

262711-fix.png

Thank you so much!!