File size: 706 Bytes
8f07272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
extends Node3D



@onready var animation_tree : AnimationTree = $AnimationTree
@onready var _playerback : AnimationNodeStateMachinePlayback = animation_tree["parameters/playback"]

enum States {IDLE, RUN, AIR}


func _ready():
    animation_tree.active = true

func transition_to(state_id: States): 
    prints("transition to ", state_id)
    match state_id:
        States.IDLE:
            _playerback.travel("Idle")
        States.RUN:
            _playerback.travel("RunBlend")
        _:
            _playerback.travel("Idle")
            
func set_velocity(velocity: Vector3):
    animation_tree.set("parameters/RunBlend/blend_position", Vector2(velocity.x, velocity.z))
    print(velocity)