[SOLVED] Adjusting 3D Camera Translation with Code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ash_Grey

Hello everyone,

I’d like some help on making my camera translate when the scene is launched, for a subtle zoom effect. However after trying many things, it’s still not working.

Here’s what I have currently:

func _ready():
    	$CameraControl/Camera.translation = lerp(Vector3(0, 0, -30), Vector3(0, 0, -10), .5)

I also tried it with a method of the parent node, which is a Spatial:

func _ready():
	$CameraControl.translate(lerp(Vector3(0, 0, -30), Vector3(0, 0, -10), .5))

I seem to be missing something here. Most tutorias I found are about making the camera follow a player, and since this is for some type of menu, following an object is not what I’m looking for. Any help will be greatly appreciated, thanks for reading.

:bust_in_silhouette: Reply From: klaas

Hi,
you know you have to “animate” the weight attribute when lerp’ing

if you lerp(value1,value2,0.5) it will always return the halfway point between value1 and value2

Have a look at the Tween object

Ahh makes sense. Thank you very much for your help.

Ash_Grey | 2021-08-06 18:51