I wonder if it is possible to run animation backwards, that is frame number decreases over time instead of increasing.
I've tried things like {x=10,y=1}, but it still runs forward and then wraps around.
[Unsolved]set_animation() running backwards?
[Unsolved]set_animation() running backwards?
Last edited by Termos on Mon Aug 05, 2019 16:57, edited 1 time in total.
Re: set_animation() running backwards?
You can set a negative animation frame speed, I just tried it out.
So
So
Code: Select all
object:set_animation({x = 1, y = 10}, -n)
Re: set_animation() running backwards?
Tried that too, animation just did not run. I'll check again.Eran wrote:You can set a negative animation frame speed, I just tried it out.
Re: set_animation() running backwards?
If you haven't got it working in the meantime, I suppose that either somewhere else your mod interferes with negative frame speeds or it's a change that's happened between the version that you use and the 5.1.0 dev version that I use.
I attached the mod I used to try this. When you start the game with it and press F7, you should see the player model play a death animation in reverse before you move or do anything. It is incompatible with player_api. The relevant code is in line 92 of init.lua
I attached the mod I used to try this. When you start the game with it and press F7, you should see the player model play a death animation in reverse before you move or do anything. It is incompatible with player_api. The relevant code is in line 92 of init.lua
- Attachments
-
- dwarf_characters.tar.gz
- (43.62 KiB) Downloaded 5 times
Re: set_animation() running backwards?
Almost got it to work.
It runs backwards sometimes, but it seems to exhibit undefined behavior, probably based on previous animation frame it sometimes skips to the last frame instantly. Also it seems to break normal forward animations which run after.
That is when frame_loop = false.
When it's looping it seems okay.
It runs backwards sometimes, but it seems to exhibit undefined behavior, probably based on previous animation frame it sometimes skips to the last frame instantly. Also it seems to break normal forward animations which run after.
That is when frame_loop = false.
When it's looping it seems okay.
Re: set_animation() running backwards?
Done some more testing, think I can say what's wrong.
If an animation follows another animation with frame_speed of opposite sign, it skips directly to the last frame.
Affects only frame_loop=false animations.
Can't say if it's a bug, cause I'm not sure negative speeds were even intended, but it probably is.
One of the test setups:
It is supposed to play alternating forth and back animations, instead, only the first one runs as expected, all the subsequent animations are skips to the last frame.
If both animations are the same sign all is good.
If an animation follows another animation with frame_speed of opposite sign, it skips directly to the last frame.
Affects only frame_loop=false animations.
Can't say if it's a bug, cause I'm not sure negative speeds were even intended, but it probably is.
One of the test setups:
Code: Select all
if mobkit.timer(self,2) then -- runs every 2 secs
if self.forth then
self.object:set_animation({x=1,y=15},7,0,false)
self.forth = false
else
self.object:set_animation({x=15,y=1},-7,0,false)
self.forth = true
end
end
If both animations are the same sign all is good.
Re: set_animation() running backwards?
So make a bug request.Termos wrote:Done some more testing, think I can say what's wrong.
If an animation follows another animation with frame_speed of opposite sign, it skips directly to the last frame.
Affects only frame_loop=false animations.
Can't say if it's a bug, cause I'm not sure negative speeds were even intended, but it probably is.
One of the test setups:It is supposed to play alternating forth and back animations, instead, only the first one runs as expected, all the subsequent animations are skips to the last frame.Code: Select all
if mobkit.timer(self,2) then -- runs every 2 secs if self.forth then self.object:set_animation({x=1,y=15},7,0,false) self.forth = false else self.object:set_animation({x=15,y=1},-7,0,false) self.forth = true end end
If both animations are the same sign all is good.
Who is online
Users browsing this forum: No registered users and 1 guest