Godot Version
4.6 stable
Question
My enemi dos not walk. : (
(I am a bad Coder)
This is my script:
extends CharacterBody2D
enum State {
PATROL,
CHANGE_DIRECTION,
}
var current_state = State.PATROL
#@onready var ray_cast_down: RayCast2D = $RayCastDown
@export var direction: int = -1
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
var move_speed = 60
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity.y += gravity * delta
match current_state:
State.PATROL:
print ("patrol")
velocity.x = direction * move_speed
func change_state(new_state: State):
current_state = new_state
# Enter new state
match new_state:
State.PATROL:
print("patrol new")
It prints both “patrol" and"patrol new”.
Thanks in advice. ![]()