(SOLVED) Need help understanding Animation Event (Spine)

C

chaotic

Guest
I'm a little bit confused on how to pull data when using the *Animation Event*
If anyone can explain or show an example on how to use this ?


I'm using Game maker EA 1.9 and animation is creating in spine 3.4.02.

In spine you can set Events to trigger during animation like footsteps. And there is options to add properties to the event which is integer, float and string value. But i'm not sure how to pull that data out.
Already tried this test in the "Animation Event"

var _string = ds_map_find_value(event_data, "string");
show_debug_message(_string);
and by default the spine "string" value is empty "".
But even tho i change it to someting like foot_hit_ground. It returns empty?
btw the event does trigger but i'm just not sure how to pull the data =/
 

Xer0botXer0

Senpai
Might want to modify title and add 'Spine' into it, also you can search the forum perhaps someone has had a similar issue while you wait. I don't use spine so unsure.
 
C

chaotic

Guest
Might want to modify title and add 'Spine' into it, also you can search the forum perhaps someone has had a similar issue while you wait. I don't use spine so unsure.
Ah thanks for the tip. I'm gonna change it now. Hmm yeah that's not a bad idea!
 

rIKmAN

Member
In the code you posted you are searching for 'string', you should be searching for whatever you called the event you are looking for in Spine.

ie. footstep

Search for your event (as named in Spine) and the value will be whatever you set in Spine (int/float/string) for the value.
 
C

chaotic

Guest
Search for your event (as named in Spine) and the value will be whatever you set in Spine (int/float/string) for the value.
Hi
Thankyou for replying. Okay, i changed it from "string" to "footstep". Now i'm getting undefined. Btw i'm kind of new to ds so it scares me a bit to use ds incase i do a memory leak or something. :3
 
C

chaotic

Guest
I'm not trying to be pushy or anything but would you mind giving me an example on how to use it correctly? or am i doing it right? :)
 

rIKmAN

Member
Is the event called 'footstep' inside Spine?

I just gave that as an example, but it should be whatever you have named the event within Spine.

I'm not home at the moment, but if you look at the manual page for skeleton_bone_state_get there is example code at the bottom you should be able to use if you change out the ds_map and key/value you are looking for.

Don't be scared of ds_maps, as you aren't going to be able to do what you want without learning a little about them.

If you are still struggling later let me know and I'll see if I can knock up a quick example.
 
C

chaotic

Guest
Yes, the event is called footstep in spine. But when i type that in game maker like so:
Code:
_array = event_data[? "footstep"];

show_debug_message(_array);
and in the compiler i get:
undefined
However when i type: name instead of footstep it shows: footstep in the compiler
You're right! I've always avoided them . But i've started to learn about them more, and i'm getting a little bit more comfortable doing ds now, just scares me a little bit that i'm doing it wrong lol. :p
 
Last edited by a moderator:
C

chaotic

Guest
And thank you for taking the time to help me out btw! really appriciate it!
 

rIKmAN

Member
Yes, the event is called footstep in spine. But when i type that in game maker like so:
Yes, the event is called footstep in spine. But when i type that in game maker like so:
Code:
_array = event_data[? "footstep"];

show_debug_message(_array);
and in the compiler i get:
undefined
However when i type: name instead of footstep it shows: footstep in the compiler
Ah there you go then, it's working!
As I said I'm not at home so I was working from memory, but if you are getting "footstep" printed in the console then that means the "footstep" event has fired and you can now do whatever you like by checking it - ie. play a sound.

Add a few more events in Spine and get them firing too, then print a different message to the console depending on which event is firing.

You can then extrapolate out from here so instead of printing a message when "footstep" is fired, you can play a footstep sound etc.
 
C

chaotic

Guest
Ah there you go then, it's working!
As I said I'm not at home so I was working from memory, but if you are getting "footstep" printed in the console then that means the "footstep" event has fired and you can now do whatever you like by checking it - ie. play a sound.
Good to hear! so i'm doing this right then! :D
Thanks for the tips!
I made event where the player is attacking and here is how i set it up when the Animation Event is triggered!
Code:
/// Get data and apply the event type
var get_event = event_data[? "name"];

if (get_event == "attack") {

    // Get Damage
    var dam = irandom_range(1, 3);

    // Create Damage Object
    var d = instance_create(x+32, y-20, Damage);
    d.damage = dam;
   
    // Create Damage Text
    var dt = instance_create(x+32, y-32, Damage_Text);
    dt.text = dam;
    attacked = true;
}
Works perfectly!
 

rIKmAN

Member
Awesome!

Congrats on getting it working - time to brush up and get comfortable with ds_* datastructures! :)
 
C

chaotic

Guest
Awesome!

Congrats on getting it working - time to brush up and get comfortable with ds_* datastructures! :)
Thank you. i'm so excited that this works now!
Yes indeed, i'm gonna be 'studying' that soon. ^^

You helped a ton so thank you again! have a good day!
 

rIKmAN

Member
Thank you. i'm so excited that this works now!
Yes indeed, i'm gonna be 'studying' that soon. ^^

You helped a ton so thank you again! have a good day!
You're very welcome! :)
I'm sure we'll cross paths again as fellow Spine + GMS users so I'll see you around!
 
Top