0 votes

I saw a previous question asking about how to make the camera follow the player but with a delay, giving it a bit of a bouncy look. The answer was to use an InterpolatedCamera, but that's 3D.
I haven't found any methods that I can use in Camera2d, so how would this be achieved?

Godot version 3.2.2
related to an answer for: Camera follow with slight delay
in Engine by (14 points)

2 Answers

0 votes

All InterpolatedCamera in 3D does is lerp the camera's transform. You can do this in 2D yourself with something along these lines:

extends Camera2D

export (NodePath) var target_path
export var speed = 10
var target

func _ready():
    if target_path:
        target = get_node(target_path)

func _physics_process(delta):
    position = lerp(position, target.position, speed * delta)

You can play around with how you move the camera depending on what effect you want. It's really just about moving the camera independent of, but linked to, the target.

by (20,475 points)
0 votes

Answered this live on stream: https://www.youtube.com/watch?v=fC3384meGZA
should be around 2 hour 25 minutes or so.

Idk if this is what you are talking about, but you can set drag margin enabled on a camera 2d, then set the margin to be 0, and then turn smoothing on.

by (576 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.