Jump to content

Multiple Keys with the same timestamp in timeline


NowSayPillow

Recommended Posts

As you can see in the following timeline for what's supposed to be a bed falling from the sky, bouncing, and landing I've got multiple keys with the exact same time stamp. Your spriter program seems to know exactly what to do with this information but anytime I load it into my project I get glitches because it *always* grabs the first key that matches the timeline, but that key isn't necessarily the correct one -- actually, it /usually/ isn't.  To make matters worse if I go into the file and modify it manually I can fix it. But then every-time our artists changes the file I have to jump through the hoops again.

 

My questions: Why does this happen? Is this supposed to happen? If not, how do I avoid it in the future? If it is, then how do I go about selecting the "correct" key?

 

Thanks

 

-- Geoff

            <timeline id="35" name="bed">                <key id="0" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="1" time="44" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="2" time="149" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="3" time="199" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="4" time="249" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="5" time="299" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="6" time="351" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="7" time="398" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="8" time="439" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="9" time="499" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="10" time="549" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="11" time="2305" spin="0">                    <object folder="1" file="0" x="111" y="1500" angle="0"/>                </key>                <key id="12" time="3014" spin="0">                    <object folder="1" file="0" x="111.000239" y="1499.999933" pivot_x="0" pivot_y="1" angle="0"/>                </key>                <key id="13" time="3014">                    <object folder="1" file="0" x="365.388731" y="1365.537347" pivot_x="0.495884" pivot_y="0.347269" angle="0"/>                </key>                <key id="14" time="3375">                    <object folder="1" file="0" x="355.061939" y="-47.96479" pivot_x="0.495884" pivot_y="0.347269" angle="10.025348"/>                </key>                <key id="15" time="3375" spin="-1">                    <object folder="1" file="0" x="135.068468" y="-126.580453" pivot_x="0.046917" pivot_y="0.157376" angle="10.025348"/>                </key>                <key id="16" time="3607" spin="-1">                    <object folder="1" file="0" x="133.297382" y="-49.772419" angle="355.753348"/>                </key>                <key id="17" time="3607" spin="-1">                    <object folder="1" file="0" x="122.148717" y="125.113834" angle="355.753348"/>                </key>                <key id="18" time="3796">                    <object folder="1" file="0" x="137.785772" y="105.939726" pivot_x="0" pivot_y="1" angle="352.726103"/>                </key>                <key id="19" time="3993">                    <object folder="1" file="0" x="97.414938" y="96.94195" pivot_x="0" pivot_y="1" angle="4.543949"/>                </key>                <key id="20" time="3993" spin="-1">                    <object folder="1" file="0" x="587.305237" y="-45.931673" pivot_x="0.929886" pivot_y="0.120216" angle="4.543949"/>                </key>                <key id="21" time="4132" spin="-1">                    <object folder="1" file="0" x="588.031518" y="-134.235504" angle="0"/>                </key>                <key id="22" time="4132" spin="0">                    <object folder="1" file="0" x="111" y="47" angle="0"/>                </key>            </timeline>
Link to comment
Share on other sites

hello, @NowSayPillow. The issue is that pivot points are being changed in the middle of the animation. If your animator isn't trying to change the pivot point, then to fix this:
On the keys that contain pivot point data in the file (12,13,14,15,18,19, and 20 - starting from 0), within Spriter right-click on the pivot point, and choose 'use default pivot point'. That should fix the issue. To avoid this in the future just always use the default pivot point (you can set the default pivot point for an image by double clicking on the image file in the file palette). That should be enough to fix the problem if you just need to get things working as quickly as possible, but I will give some information below on why this is happening (not a bug), and how you can make your engine support the feature, which is very simple.

Spriter has two features: changing pivot points and dynamic reparenting, which work by putting two different sets of transformable data for the same object at the same time. You can seamlessly change pivot points in the middle of an animation, which would normally result in the image suddenly visually teleporting to a new location. You can also seamlessly change an object's parent bone, or add or remove it from the skeleton completely, both of which are usually not allowed mid animation.

To support this in your own engine (feel free to ignore this part if you don't have access to the engine source code or it's developer):
If you're already using the 'object_ref's and 'bone_ref's in the mainline' 'key's to find your individual 'timeline's and 'key's, always tween from the exact 'key' it indicates, and the very next 'key'. The ref's will already point exactly where the data you need is without any further checks.

 

If you're not using the 'timeline' and 'key' tags in the 'object_ref's and 'bone_ref's and are instead running through 'timeline's and 'key's individually and searching for the key at the current time in your code, just make sure you're always tweening between two consecutive keys. For example if you have 4 keys in a row:

<key id="0" time="0"/><key id="1" time="10"/><key id="2" time="10"/><key id="3" time="20"/>

If the current time is 5, you should tween between the first two 'key's.
If the current time is 15 you should tween between the last two 'key's.
The only special case is if the time is exactly 10, then rather than just use the data at <key id="1">, if the current time is the exact time of a 'key', then you still check the next 'key' to make sure it doesn't also have the same time. If it does (and it does in this case), then you should use the second 'key'. You don't have to check any more 'key's. The maximum duplicate time 'key's that will appear in a row is 2.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...