Easy Animation Tree Question

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ItzZac

Alright, this one will probably be an easy one, and I really feel like the answer is right in front of my face and I’m just missing it but here it goes:
I have an animation tree for a bat enemy that looks like this:

[Hang] ---->----[Wake]---->|----[Idle]

And a script that looks like this:

extends KinematicBody2D

const MAX_SPEED = 80
const MAX_HEALTH = 10

var player = null
var state_machine
var motion = Vector2.ZERO
var direction = 1
var dead = false
var awake = false
var chase = false
var hover = false

func _ready():
state_machine = $AnimationTree.get(“parameters/playback”)

func _physics_process(delta):

func _on_Agro_body_entered(body):
if “Hermit” in body.name and awake == false:
print(“The Bat sees you!”)
player = body
awake = true
chase = true

As you can see the code is still in progress and I haven’t written in the functions for many of the variables. But “The Bat sees you!” is being printed, so I know that section of the code is running. However, the “Wake” animation of my bat is never being triggered and I can’t figure out why. Any ideas?

Also side question: I dont think I’m using the {} brackets to link code right. I’m clicking the {} button in the comment editor and then pasting my code where it says “enter code here” but it keeps coming out weird.

If you’re wondering how to properly format the code in your questions, use four spaces for each line of code.

Ertain | 2021-01-22 09:29

Thanks for the replies guys. clemens, unfortunately that doesn’t solve my issue. I did learn a couple things so thanks for the link regardless. However, I’m not getting any errors when running my code, the animation is simply not playing and the rest of the game proceeds as usual.

ItzZac | 2021-01-23 02:25