Nate wroteThere is no bug? My favorite kind of bug! :clap:
there was a BUG! IN THE past, you got lucky (punk) with new runtimes
06 Jul 2016, 14:26
Nope. I was wrong! it still happens.
What do you need from me to help investigate this issue.
I cant get the bug to happen when break pointing now, so I'm stuck with debug logs,
Loading Image
Here I have one animation running, Attack_Knife_intro
(60 frames track 0). Then I interrupt that animation (I damage the character) and it plays an animation TakeHit_Upper
( 30 frames track 0). On the same frame, I play animation Attachment_Knife_Off
(1 Frame, track 1)
Attack_Knife_intro
Turns Attachment knife_a
ON, in slot WeaponA
- first frame.
TakeHit_Upper
DOES NOT ALTER slot WeaponA
, At all.
Attack_Knife_intro
Turns Attachment knife_a
OFF, in slot WeaponA
- first frame.
The above image shows the following, the current anuimation playing (_anim_) and any time an attachment is set, in the format slot
: current image
to new image
currenttime
06 Jul 2016, 14:45
I have repo'ed it in a project using latest unity runtimes and goblin-mesh (altered)
It uses the script animationstuff to handle playing of animations,
https://drive.google.com/file/d/0B5ElW0WUt28eMG1UWlgtTGFoUXM/view?usp=sharing
06 Jul 2016, 14:54
its in the goblin scene
06 Jul 2016, 16:50
I have narrowed down the problem to
previous.animation.Apply(skeleton, previous.lastTime, previousTime, previous.loop, null);
line 119 Animation state. bug is fixed by removing it.
However, I am unsure why this line even exists. All this does is play the previous animation.
Take the attachment time like (only visable one causing a problem)
public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame.
int frameIndex;
if (time >= frames[frames.Length - 1]) // Time is after last frame.
frameIndex = frames.Length - 1;
else
frameIndex = Animation.binarySearch(frames, time, 1) - 1;
String attachmentName = attachmentNames[frameIndex];
skeleton.slots.Items[slotIndex]
.Attachment = attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
}
for any timelines' frame < current time, it will apply it. However, this does not account for the current state of the attachment. I.e. if another track has turned it off.
I have noticed that you don't check the timeline's frame time against lastTime
. Is this so it never misses an attachment keyframe?
06 Jul 2016, 17:05
I changed the code to:
public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame.
int frameIndex;
if (time >= frames[frames.Length - 1]) // Time is after last frame.
{
if (lastTime >= frames[frames.Length - 1]) // you missed your chance
return; //now bugger off
frameIndex = frames.Length - 1;
}
else
frameIndex = Animation.binarySearch(frames, time, 1) - 1;
String attachmentName = attachmentNames[frameIndex];
skeleton.slots.Items[slotIndex]
.Attachment = attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
}
It works, but I am unsure what knock-ons it will have.