extends KinematicBody2D export var weight = 8 export var max_speed = 48 # ~3 tiles/sec at top speed export var friction = 500 export var speed = 20 var target_player = null remotesync var velocity = Vector2.ZERO remotesync var acceleration = Vector2.ZERO enum { IDLE, WANDER, CHASE, ATTACK } var state = IDLE func _ready(): rset_config("position", MultiplayerAPI.RPC_MODE_SLAVE) func _physics_process(delta): match state: IDLE: if target_player != null: state = CHASE else: rset_unreliable("acceleration", Vector2.ZERO) WANDER: pass CHASE: if target_player == null: state = IDLE else: rset_unreliable("acceleration", (target_player.global_position - global_position).normalized() * speed) ATTACK: pass rset("velocity", move_and_slide((velocity + acceleration).clamped(max_speed), Vector2.ZERO, false, 4, 0.785398, false).move_toward(Vector2.ZERO, friction * delta)) if velocity.x < 1: $sprite.flip_h = true elif velocity.x > 1: $sprite.flip_h = false if is_network_master(): rset_unreliable("position", position) func seek_player(): pass func _on_hurtbox_die(_a, _b): print("slime die") rpc("die") remotesync func die(): queue_free() func _on_hurtbox_hit(): print("slime hit")