- تم التحرير
3.5+ Attachments over multiple tracks.
Hello,
We have a character which may hold a weapon, and will attack (play animation) with that weapon. This weapon has durability and will break after it hits X amount of objects. (we do not know if the sword will break before we play the animation)
Upon the sword breaking, we need to turn the SwordAttachment
visibility to off, however we want the animation to continue.
Our SwordSwing
Animation keys the SwordAttachment
visibility on, on frame 0. This is playing on track 0.
We play this animation, and at frame 30, we decide that the durability of this weapon is up, and we play an SwordOff
Animation. Which on frame 0 keys SwordAttachment
(and SwordSlot
) visibility to off. This is played on track 1.
It needs to be on a different track because SwordSwing
animation still needs to play and finish.
The result of this, is the SwordAttachment
visibility is on, as you run though all the attachment timelines in an animation, every frame.
How is best to proceed, to turn the attachment off, even though there is an animation which once keyed it on currently playing.
I have simplified the problem, we key SwordSlot
multiple times in the animation
Simplified SwordSwingAnimation
, playing on track 0
Image removed due to the lack of support for HTTPS. | Show Anyway
Frame 25 is when we would play SwordOff
, on track 1
Image removed due to the lack of support for HTTPS. | Show Anyway
BinaryCats wroteThe result of this, is the SwordAttachment visibility is on, as you run though all the attachment timelines in an animation, every frame.
This part doesn't make sense.
Does it work in Skeleton Viewer? It should. How do you play SwordOff
? If it is non-looping, it will be removed when it hits TrackEntry trackEnd
. You could set trackEnd
to something high, or maybe the SwordSwingAnimation duration minus the SwordSwingAnimation's trackTime
so when the sword swing is done, so is turning off the sword.
Nate wroteThis part doesn't make sense.
if (mix == 1) {
for (int ii = 0; ii < timelineCount; ii++)
timelinesItems[ii].Apply(skeleton, animationLast, animationTime, events, 1, true, false);
}
This code in the animationstate.cs apply, applies all of the keys in the animation. rather than only doing the LastTime to now key frames.
Does SkeletonViewer support multiple tracks, last time I used it it didn't :s
The animation is non looping.
Oh I see, I could also loop it and end the loop on the end event of the animation. however its kind of annoying if something where to interrupt this animation, the sword would be visible (in any of the solutions given this would happen if the animation where to be interrupted)
Why isn't your game logic simply setting the Slot to null with SetAttachment() so that it breaks at exactly the right time it happens in game? You could then adjust your damage appropriately in the event he is half way done with the swing and then basically whiffs and the hitbox event in your spine would fire or however you do hitboxes.. and the character is now doing 0 damage (because when you null'd the slot in code you also changed the Player script's damage output).
Because the animation would reset it. Bare in mind that there are multiple weapons, over multiple slots. there are weapons that use multiple slots. There are weapons that use multiple images in one animation. its easier to control what attachments are visible and which are not though animations rather than arbitrary code,
I wouldn't say it's easier. This is related to your other thread. You have the model (the game state, "is the sword equipped") and the view (the skeleton, "is the sword equipped"). Both need the same information. You have been storing that information in two places, which can work but has the potential that they get out of sync. I'd say it would be easier if the model was the authority and the view simply used the value from the model, like this.
what? that is what we do. Ive said this. but if say, you want to unequipt the sword, while an animation(that keys that an attachment in that slot visibility) Is playing. it will key it off for one frame, then end, and the other animation will reset the slot as it does not use lasttime to now.