OstyLock

Hi,
I downloaded sample project form https://github.com/EsotericSoftware/spi ... /spine-xna. I just wanted to test how it works in XNA and I found a little problem with RotBone.Rotation while I play an animation.

Screenshots and video below show the problem.

1. This is how walk animation should looks like.


2. Here is wrong walk animation.


3. Another example of wrong walk animation.


Youtube video:
http://youtu.be/MNyCdmQ2xA4

I use a trial version of Spine so I can't check other Timelines.
In Update function I added a few lines of code:
//***********************************************
if(st.IsKeyDown(Keys.R))
{
if (state.Animation.Name != "jump")
{
state.SetAnimation("jump", true);
}
}

if (st.IsKeyDown(Keys.W))
{
if (state.Animation.Name != "walk")
{
state.SetAnimation("walk", true);
}
}

// here RotBone.Rotation is OK
if (st.IsKeyDown(Keys.Space))
{
if (state.Animation.Name != "jump")
{
state.SetAnimation("jump", false);
state.AddAnimation("walk", true);
}
}
//**********************************************
I've tested it with stateData.SetMix "on" and "off" but the problem still exists.
Maybe I do something wrong, but I think the problem is connected with spine-runtimes.
OstyLock
  • 記事: 2

OstyLock

I found the reason of problem which I described in my previous post. This problem can occurs in any animation that doesn't save all parameters.
Picture below shows "jump" animation:


There is rot.Rotate parameter saved in this animation. However "walk" animation doesn't has this parameter.
That's why when "jump" animation switch to "walk" animation, "walk" gets random rotation parameter from previous "jump" animation.

It can be repaired by forcing to save all parameters (rotation, scale, translation).
It's also possible to add missing timelines.

In "SkeletonJson.cs" I added a few lines of code to repair missing RotateTimeline.
//******
private Dictionary<BoneData, Dictionary<Timeline, object>> BoneDataLib = newDictionary<BoneData,Dictionary<Timeline, object>>();
//******

//******
// BoneDataLib = new Dictionary<BoneData, Dictionary<Timeline, object>>();
BoneDataLib.Clear();
for (int x = 0; x < skeletonData.Bones.Count; x++)
{
BoneData b = skeletonData.Bones[x];
if (BoneDataLib.ContainsKey(b) == false)
{
BoneDataLib.Add(b, new Dictionary<Timeline, object>());
}
}
//******



//******
BoneData OrginalBone = skeletonData.Bones[boneIndex];
BoneDataLib[OrginalBone].Add(timeline, timeline);
//******


//******
foreach (KeyValuePair<BoneData, Dictionary<Timeline, object>> val in BoneDataLib)
{

Type t = typeof(RotateTimeline);

bool ValNotExist = true;
foreach (KeyValuePair<Timeline, object> lin in val.Value)
{
if (lin.Value.GetType() == t) { ValNotExist = false;}
}

if (ValNotExist)
{
RotateTimeline tlrot = new RotateTimeline(2);
tlrot.SetLinear(0);
tlrot.SetFrame(0, 0, val.Key.Rotation);
tlrot.SetFrame(1, duration, val.Key.Rotation);
tlrot.BoneIndex = skeletonData.FindBoneIndex(val.Key.Name);
timelines.Add(tlrot);
}
}
//******
Below I put link to modified file "SkeletonJson.cs".
http://center.nstrefa.pl/spine/SkeletonJson.cs
OstyLock
  • 記事: 2

Nate

This is a bit of a gotcha with all the runtimes. I've been collecting things like this for a FAQ, just need to find time to put together a webpage with it all. See here for more info:
http://esotericsoftware.com/spine-using ... on-changes
アバター
Nate

Nate
  • 記事: 9642


Return to Bugs