Need guidance on animation code

Your forum for all discussions around Modding.
User avatar
HatsuneKid
Posts: 27
Joined: Thu Jul 30, 2020 5:15 am

Need guidance on animation code

Post by HatsuneKid »

There is a hooklift trailer whose unloading animation code is as follows:

Code: Select all

        <animation name="unloading">
            <part node="controlLever" startTime="0" endTime="0.1" direction="1" startRot="0 0 0" endRot="0 0 -20"/>
            <part node="controlLever" startTime="0.1" endTime="9.9" direction="1" startRot="0 0 -20" endRot="0 0 -20"/>
            <part node="controlLever" startTime="9.9" endTime="10" direction="1" startRot="0 0 -20" endRot="0 0 0"/>
            <part node="controlLever" startTime="0" endTime="0.1" direction="-1" startRot="0 0 0" endRot="0 0 20"/>
            <part node="controlLever" startTime="0.1" endTime="9.9" direction="-1" startRot="0 0 20" endRot="0 0 20"/>
            <part node="controlLever" startTime="9.9" endTime="10" direction="-1" startRot="0 0 20" endRot="0 0 0"/>
        </animation>
I want that control lever to rotate at different angles in both directions of unloading the animation. This is to simulate the rotation of the control lever in different directions to control the lifting and lowering of the dump bucket. And it work well without any error.

The problem is once I cancel the unloading process midway, control lever will not immediately rotate to the another direction. Cause the triggering time of its rotation is only at the beginning and end of the unloading process. So how to write animation code to achieve that the control lever can switch states and rotate to another positions at any time during the unloading process?