extends CharacterBody2D var state var max_speed = 200 @onready var anim = $AnimatedSprite2D
func _ready(): pass
func _process(delta): var movement = movement_vector() var direction = movement_vector().normalized() velocity = max_speed * direction move_and_slide() if direction != Vector2.ZERO : $AnimatedSprite2D.play("run") else: $AnimatedSprite2D.play("idle") if Animation == "attack" and get_frame() = 12: state = false
func movement_vector(): var movement_x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left") var movement_y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up") return Vector2(movement_x,movement_y)
func _input(event): if Input.is _action_pressed("attack"): play("attack") state = true вот ко на всякий случай
var state
var max_speed = 200
@onready var anim = $AnimatedSprite2D
func _ready():
pass
func _process(delta):
var movement = movement_vector()
var direction = movement_vector().normalized()
velocity = max_speed * direction
move_and_slide()
if direction != Vector2.ZERO :
$AnimatedSprite2D.play("run")
else:
$AnimatedSprite2D.play("idle")
if Animation == "attack" and get_frame() = 12:
state = false
func movement_vector():
var movement_x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
var movement_y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
return Vector2(movement_x,movement_y)
func _input(event):
if Input.is _action_pressed("attack"):
play("attack")
state = true
вот ко на всякий случай