2D - Make the camera follow the player into spawn point if they die

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

Hey so I can’t figure out what will the timer be to set the camera smoothing speed into default, like for example i died because of a spike or void, my code will set the position of the kinematic body into my spawn point but I don’t know what the timer of my yield would be. so are there any way to determine the time?

The Problem Video

func _on_Area2D_body_entered(body):
if body.name == 'Player':
	is_alive = false
	yield(get_tree().create_timer(2.3),"timeout"); cam.smoothing_speed = 2
	position.x = -168
	position.y = -9
	is_alive = true
    cam.smoothing_speed = 5

whatever time you put on the yield will only delay triggering the rest of the code. The smoothing speed will remain at 5. Not sure what you are asking. What is that you want to achieve? determine the time for what purpose?

Pomelo | 2022-07-25 17:26

Im setting the smoothing speed to 5 to make it default so it’ll not stay as 2 smoothing speed which my code changes above.

Shineurysm | 2022-07-25 17:35

so basically i want to predict how much time the camera will go back to player position which i will use to create a timer to set my smoothing speed to 5

Shineurysm | 2022-07-25 17:37

Not sure if i explained it correctly but im stuck on this problem since yesterday lol

Shineurysm | 2022-07-25 17:38