Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | alexgomez141 |
I have a camera2d set up to update it’s global position when player enters a new area. It does this through updating a singleton variable “camera_position” when it enters that new area. When the player dies, I reload the scene. However, there is a quick jerk from the original position (when reloaded) to the new position. Anyone know how to fix this? Camera’s are particularly hard for me to learn
Here is code snippet:
Camera2D:
func _ready():
global_position = GameState.camera_position
(Singleton) GameState:
var camera_position = Vector2.ZERO
var player_position = Vector2(34,121)
Area2D:
func body_entered(body):
if body.name == "Player":
GameState.camera_position = global_position
GameState.player_position = body.global_position