0 votes

Hi All!
I have a scene set up in which the camera follows a rigid body using the lookatfrom_position function. Is it possible to interpolate its movements with something like lerp so that the movements are smoother and a tad delayed. I am after something like this, only in 3d:

https://docs.godotengine.org/en/3.1/_images/interpolation_follow.gif

in Engine by (483 points)

This looks more like the classic velocity trick (vector3 - vector3)*-1 and use it as velocity to the camera

Thanks. How do you use this trick in conjunction with 'look at from position'? As in, what is the syntax? Do you have an example?

1 Answer

0 votes
var c
var vel = Vector3()
var speed = 2

func _process(delta):
    var a = $RigidBody.global_transform.origin
    var b = c.global_transform.origin
    # adds cam position from body
    b = Vector3(b.x+2,b.y-2,b.z)
    # cam velocity
    vel += ((b-a)*-1)*(delta*speed)
    # cam pos + velocity
    c.look_at_from_position(vel,a,Vector3(0,1,0))

func _ready():
    c = Camera.new()
    c.current = true
    add_child(c)
by (195 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 Frequently asked questions and 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.