I’m trying to get the camera to follow the target, but it only moves towards the target and doesn’t stay with it.
there is the code
var direction_speed : float = 155
enum PLAYER_STATE {CAM_CONTROLL, CANT_CONTROLL}
var PLAYER_ = PLAYER_STATE.CAM_CONTROLL
var GetPositionMeh : Vector2
func _process(delta):
match PLAYER_:
PLAYER_STATE.CAM_CONTROLL:
if(Input.is_action_pressed("W")):
transform.origin += Vector2.UP * direction_speed * delta
pass
if(Input.is_action_pressed("S")):
transform.origin += Vector2.DOWN * direction_speed * delta
pass
if(Input.is_action_pressed("A")):
transform.origin += Vector2.LEFT * direction_speed * delta
pass
if(Input.is_action_pressed("D")):
transform.origin += Vector2.RIGHT * direction_speed * delta
pass
pass
PLAYER_STATE.CANT_CONTROLL:
position = position.lerp(GetPositionMeh, delta / 0.1)
pass
pass
func _on_area_click_player_controll(SelfPosition:Vector2) -> void:
PLAYER_ = PLAYER_STATE.CANT_CONTROLL
GetPositionMeh = SelfPosition
pass
Also I would like to know if there is a logical error in the code but in my vision it looks great and I apologize for the bad English in the code…