im currently having a problem with a statemachine that i am coding, the problem that is occurring is that when i add move_and_slide to the state of movement, the if condition at the last of the code block is getting the error:
the method " move_and_slide isn't declared in the current class
extends Node2D
class_name State
var state_machine = null
var player_velocity = Vector2()
var player_speed = 200
enum playerStates{IDLE, WALK, RUN, USE, SHOOT}
enum ItemStates{ITEM_ON_GROUND, IS_EQUIPED}
func _ready():
if Global.player_isIdle == State.state_machine == playerStates.IDLE:
pass
if Global.player_isWalking == State.state_machine == playerStates.WALK:
player_velocity = Global.player_velocity
func handle_input(_event: InputEvent):
if player_velocity != player_velocity.ZERO:
if Global.player_isWalking == State.state_machine == playerStates.WALK:
pass
if Global.player_isRunning == State.state_machine == playerStates.RUN:
if Input.is_action_pressed("sprint"):
player_speed = 300
Global.player_velocity = Global.player_velocity.normalized() * player_speed
Global.player_velocity = move_and_slide(Global.player_velocity)
func _physics_process(_delta):
pass