Hello again!
Self explanatory subject here, I'm trying to access the current animation frame. I know it may be the simplest thing to do, but I don't know how. Halp?
I use c# for scripting and it would also be great if someone told me where to find an api or just a list of all the Spine runtime functions and their descriptions.
Cheers!
1. sayfa (Toplam 1 sayfa)
pixelmeat
7 years ago
-
pixelmeat - Mesajlar: 50
Pharan
float currentTime = 0f;
int currentFrame = 0;
var currentTrack = mySkeletonAnimation.state.GetCurrent(0); // May be null if no animation is playing.
if (currentTrack != null) {
currentTime = currentTrack.time;
currentFrame = currentTime / 30f; // convert seconds to Spine editor dopesheet "frames". Spine doesn't actually use frames.
}
int currentFrame = 0;
var currentTrack = mySkeletonAnimation.state.GetCurrent(0); // May be null if no animation is playing.
if (currentTrack != null) {
currentTime = currentTrack.time;
currentFrame = currentTime / 30f; // convert seconds to Spine editor dopesheet "frames". Spine doesn't actually use frames.
}
Spine-Unity Docs Repo, and check out the Unofficial Spine Users Tumblr.
7 years ago
-
Pharan - Mesajlar: 5366
pixelmeat
Thank you!
Any hint about Spine functions documentation?
-- 13 Nov 2015, 09:48 --
Just some corrections to Pharan code here:

Any hint about Spine functions documentation?
-- 13 Nov 2015, 09:48 --
Just some corrections to Pharan code here:
var currentTrack = skeletonAnimation.state.GetCurrent(0); // May be null if no animation is playing.
if (currentTrack != null)
{
currentTime = currentTrack.time;
currentFrame = Mathf.RoundToInt(currentTime * 30f); // convert seconds to Spine editor dopesheet "frames". Spine doesn't actually use frames.
if (currentFrame >= 3) startJump = true; //Here you can trigger things using currentFrame. Be aware that this is not precise, as the exact frame you aim for may have passed by the time you check it, thus the ">=".
}
I hope someone finds this useful if (currentTrack != null)
{
currentTime = currentTrack.time;
currentFrame = Mathf.RoundToInt(currentTime * 30f); // convert seconds to Spine editor dopesheet "frames". Spine doesn't actually use frames.
if (currentFrame >= 3) startJump = true; //Here you can trigger things using currentFrame. Be aware that this is not precise, as the exact frame you aim for may have passed by the time you check it, thus the ">=".
}

7 years ago
-
pixelmeat - Mesajlar: 50
Pharan
If you just wanted something to happen at a certain time, you could have used Spine Events.
http://esotericsoftware.com/spine-events.
Much cleaner.
http://esotericsoftware.com/spine-events.
Much cleaner.
Spine-Unity Docs Repo, and check out the Unofficial Spine Users Tumblr.
7 years ago
-
Pharan - Mesajlar: 5366
pixelmeat
I just saw your answer. I will check events asap, as they could be a great help for triggering hits in my game.
Thanks Pharan!
Thanks Pharan!
7 years ago
-
pixelmeat - Mesajlar: 50
Pharan
You can find a sample of C# event syntax here: https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-unity/Assets/Examples/Scripts/BasicPlatformerController.cs#L81
This is the script from the sample BasicPlatformerController scene.
This is the script from the sample BasicPlatformerController scene.
Spine-Unity Docs Repo, and check out the Unofficial Spine Users Tumblr.
7 years ago
-
Pharan - Mesajlar: 5366
Mark topic unread
• 1. sayfa (Toplam 1 sayfa)
Dön Unity
- Tüm zamanlar UTC