I recently moved over from unity and I was wondering if anyone could help or link me to any articles that go over how to implement cinemachine’s “simple follow” (or “lazy follow” as it’s now being called).
This type of “lazy follow” is seen in older games like majora’s mask. I assume there’s a name for it but I don’t personally know it. Here’s an example:
As you can see, link can “run around” the camera. The camera only cares that link is a certain distance away, not the direction he is moving in, which is actually explained by cinemachine in their documentation:
Lazy follow interprets the offset and damping values in camera-local space. This mode emulates the action a human camera operator would take when instructed to follow a target.
The camera attempts to move as little as possible to maintain the same distance from the target; the direction of the camera with respect to the target does not matter. Regardless of the orientation of the target, the camera tries to preserve the same distance and height from it.
My current implementation is this:
extends SpringArm3D
@export var target: Node3D
func _process(delta):
if target:
position = target.global_position
Unfortunately, I cannot show how my camera behaves on account of this being my first post, but my camera prefers keeping a certain offset to it’s target rather than simply a distance like the “lazy follow”.
I’m hoping someone can help by either giving some ideas or by linking me to any articles that go over how developers handled this implementation in the past. Even just naming the technique will help as well.
You will likely need a camera that isn’t directly attached to the player. What I’d do with this issue:
Add a node structure that contains the camera and a spring arm under the player. I’m ready(), mark it as top-level. Player movement should be expressed relative to the camera (so pushing left and right will make the player run on the camera right direction, so that if you hold right, you’ll run in a circle around the camera. After the player has moved, the camera should look_at() the player. After this step, position your spring arm node from player to camera. Adjust camera position based on spring arm length. Note you could use a ray cast node too if you aren’t using the shape property of a springarm
Hello have you fixed it? I think I have a solution but I need help with moving the camera around with the mouse or touching the screen. (sorry for my english is not my first language).
To achieve the “simple follow” i used an idea from Little Polygon’s article on third person cameras which is to get the cross product of the camera’s forward direction and the camera target’s velocity. The code i came up with ended up looking something like this:
var target_velocity = last_target_position - target.position
var heading = global_basis.z.cross(target_velocity).y
# speed is important as it determines how fast the camera turns
# 1800 was a good value for my purposes
var speed = 1800.0
# delta is for lazy frame independence
rotation_degrees.y += speed * delta * heading
Also, i haven’t messed around with using mouse or touch controls to move the camera, but here’s a little something i came up with for mouse controls: