How do you move the camera based on player's velocity?

So i’ve got this 2D styled game (the game is in 3D though), and player controls a ship that flies around the screen on the X and Y axis. The camera that is in use is in the space ships actor. The camera’s rotation is locked, so it doesn’t face the way the player does, the player also just keeps sliding the way they were going when they stop thrusting, turning only re-orientates you.

So what I want to happen is have the camera not be focused exactly on the ship, but rather move in front of the actor in the direction it’s currently moving, not based on the actors rotation and current thrusting because the game is in space, and when you stop thrusting you just keep floating whatever way you where going.This is why i was wanting this to be based on the actors velocity, So if it’s not moving and sitting still the camera would be dead centre. And if it was flying off to the left and looking the other way but not thrusting the camera would stay over to the left.

I just have absolutely no idea how to go about this. I was thinking on the event used to move the ship forward i could check the velocity of the ship and it’s direction and then somehow move the camera but I have no idea and could use some help getting pointed in the right direction.

have you tried using a spring arm and enable the “camera lag” option? Make the spring arm as a child of your rocket and the camera child of the spring arm. Maybe this achieves the look you want?

There’s probably a dozen different ways to do it, here’s one quick & crude implementation:

  • this is running on Tick
  • for simplicity sake the Springarm is set to Absolute Location so you do not need to inverse transform velocity and all that jazz
  • the Out Range B on the Map Range node dictates the weight of velocity importance on the overall camera location
  • it ignores forward vector and cares about velocity only
  • there’s no camera lag here as it would have the opposite effect (leaving the camera behind rather than placing it ahead)

Image from Gyazo

This can be vastly improved depending on what’s needed. Hopefully this helps a bit.

Thanks a ton for this! This is helps a lot and is way more than i was expecting, I’ve got a few ideas so I’ll have a play around with what you’ve given me. Again thank you!

Yeah i’ve had a play around with that, if I could add negative numbers into it’s lag parameters I’d probably get something close but sadly not. I wanted the camera to move in front of the ship in the same way it lags behind, but it also just hangs around in this new forward potion until you start going another way.