extends MovementComponent ## Constants available to you # UP = -1.0 # DOWN = 1.0 # LEFT = -1.0 # RIGHT = 1.0 # Avalable functions to call # A Series of helper functions # go_up(): # go_down(): # go_left(): # go_right(): # stop(): var entered_screen = false var jump_var = false var last_player_direction: float func process(delta): if entered_screen: if current_movement_state == "idle": # Only check the player direction in idle because we don't want to track the player during jump if owner is Actor: last_player_direction = sign((owner.global_position.direction_to(PlayerInfo.player_position)).x) jump_var = true desired_movement_vector.x = last_player_direction else: desired_movement_vector.x = last_player_direction jump_var = false return func wants_jump() -> bool: return jump_var ## Other needed variables # desired_movement_vector: Vector2 - Used to store desired movement depending on the state # current_movement_state:String - The name of the current State # Since animactor state machine can actually view properties from this type # I'm thinking about moving the velocity tracker in here instead of player. # velocity: Vector2 - Current velocity, you can change this at will but state may modify it # Declare any other member variables here. Examples: # var a = 2 # var b = "text" # Called every frame. 'delta' is the elapsed time since the previous frame. # you do not normally need to define this for Actor #func process(delta): # pass # For Enemy and NPC Actors: # should be called on the frame process. # For Player Actors: # Should be called on the input process func _on_VisibilityNotifier2D_screen_entered(): entered_screen = true print("Spider wants to play!!!")