I want when player moves the crouser the animation state changes (im using animation tree) based on the crusor placement. here is the code:
@onready var state_machin = animationtree["parameters/playback"]
enum {IDLE, RUN, GUN}
var state=IDLE
var blend_pos:Vector2=Vector2.ZERO
var blend_pos_path=[
"parameters/idle/idle_bs2d/blend_position",
"parameters/run/run_bs2d/blend_position" ,
"parameters/gun/gun_bs2d/blend_position"
]
var anime_state_key=[
"idle",
"run",
"gun"
]
func move(delta):
var input_vector
if aim==true:
state=GUN
if Input.is_action_just_pressed("aim") and gun and on_stairs==false:
aim=true
state=IDLE
velocity=Vector2.ZERO
if Input.is_action_just_released("aim"):
state=IDLE
aim=false
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and aim==true and canShoot:
var dir= get_global_mouse_position()-position
shoot.emit(position,dir)
canShoot=false
$Timer.start()
func _physics_process(delta):
move(delta)
animate()
func animate()->void:
state_machin.travel(anime_state_key[state])
animationtree.set(blend_pos_path[state],blend_pos)
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
var angle: float = rad_to_deg(global_position.angle_to_point(event.global_position))
# change position in animationtree
ok but how should i change? I dont know what codes use for it, based on the animation tree… based on the codes where should i put this… mate im a noob