Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] animation issue

Hi,I'm working on a script which manage the doors. I want it simple just select a line (like on the dynamic lightning layer) and clic on a buton to get a switch to open or close the door (automatically linked them). After some coding it worked and I also manage to create a door picture, align and scale it with the path and create an animation to open it or close it.The animation is quite simple for now, it just slide it progressively. The path animation work smoothly (as the lighning calculation) but the picture movement it weird (slow at the begining and very fast at the end). I don't understand why... <a href="https://github.com/Dark11Wolf/roll20/blob/master/switchDoor.txt" rel="nofollow">https://github.com/Dark11Wolf/roll20/blob/master/switchDoor.txt</a> To reproduce just select a line and use the command "!switchDoor -create", after that click on the switch on the token layer and click on animation buton, choose a sliding direction you will see correct calculation and smoth lightning reveal (if you have a lighting source of course) but a weird movement for the picture&nbsp;
1598449183
The Aaron
Roll20 Production Team
API Scripter
The setTimeout() and setInterval() functions are not guaranteed to be precise. They will wait at least as long as the specified time, but could wait quite a bit longer depending on what else is happening. To get smoother animations, base your position on elapsed time rather than number of calls. The basic process is: Figure out how long you want to rotation to take. (RT) Record the current time (ST) Delay a call to a function to do the work In the function, check the time (CT), Calculate the percentage elapsed PE = (CT-ST)/RT If PE is &gt;= 1, set the final rotation and you're done. Else set rotation to PE * total rotation desired and goto step 3 &nbsp; That should give you a smooth animation.&nbsp;
Thanks for the answer. I added in the log the duration elapsed from the animation start. For now I haven't modidy the calculation because it seems quite regular at least compared to the laggy animation. I recorded it during the opening and we clearly see a suddent burst during the animation which doesn't appear during the log Weird Animation and the log "API SD ==&gt; animation progressing : 0 / 15 : 68..." "API SD ==&gt; animation progressing : 1 / 15 : 133..." "API SD ==&gt; animation progressing : 2 / 15 : 200..." "API SD ==&gt; animation progressing : 3 / 15 : 266..." "API SD ==&gt; animation progressing : 4 / 15 : 332..." "API SD ==&gt; animation progressing : 5 / 15 : 398..." "API SD ==&gt; animation progressing : 6 / 15 : 464..." "API SD ==&gt; animation progressing : 7 / 15 : 530..." "API SD ==&gt; animation progressing : 8 / 15 : 597..." "API SD ==&gt; animation progressing : 9 / 15 : 663..." "API SD ==&gt; animation progressing : 10 / 15 : 728..." "API SD ==&gt; animation progressing : 11 / 15 : 795..." "API SD ==&gt; animation progressing : 12 / 15 : 861..." "API SD ==&gt; animation progressing : 13 / 15 : 927..." "API SD ==&gt; animation progressing : 14 / 15 : 992..." "API SD ==&gt; animation progressing : 15 / 15 : 1059..."
1598467676
The Aaron
Roll20 Production Team
API Scripter
That is weird. Since graphics are already tweened from point a to b on a move, you could just move it directly to the final location. You're going to have a hard time syncing the drawing to the graphic. You might need to move in greater increments less often to get a smooth appearance. &nbsp;
I totally forgot the innate animation done by roll20 during a token movement ! You've right I will change the animation of the door to do it less often. Thans again