I’m having some trouble with making a third person camera. Right now I have been able to make the camera rotate with the camera angle however it is always on and haven’t been able to add any lerp to the camera follow. I saw someone on the forums was able to implement it with a universal camera but, was having trouble implementing it myself.
Adding a Playground with what you have tried to implement would be helpful.
Adding @PolygonalSun as well
So, working under a couple of assumptions:
- Assuming that the camera should ONLY move to the rear when the player is moving (ie. active user movement input)
- The follow mechanics only matters on the X/Z Axes.
The first thought that comes to mind is to add some code to your player movement inputs that gets a vector for the rear of where your player character is facing, make a vector that’s got an absolute position of one unit to the right (eg. absRight = player.position.add(1,0,0)
or something like that), and using something like Vector3.GetAngleBetweenVectors3(player.position, rear, absRight)
to get an angle and just lerp to that value when the player is moving. The math and logic may be a bit more complex than this but basically, the ArcRotateCamera calculates its horizontal angle (alpha) using relative position (1,0,0) as 0 radians. Unless the camera is parented to something, this alpha will always be calculated in world space. Here’s a sort of visual representation of what I was thinking.
Hopefully, something like this might at least inspire a solution.
This is a PG, I’m not sure if it’s what you need
I wasn’t able to add my PG since my PSU went out and I’ve been recreating my logic again from memory. I implemented someone similar with the player/camroot rotating to follow the camera alpha while moving but was looking for something more smooth.