[Unsolved]set_animation() running backwards?

Post Reply
Termos
Member
Posts: 372
Joined: Sun Dec 16, 2018 12:50

[Unsolved]set_animation() running backwards?

by Termos » Post

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.
Last edited by Termos on Mon Aug 05, 2019 16:57, edited 1 time in total.

Eran
Member
Posts: 123
Joined: Fri May 03, 2019 16:46

Re: set_animation() running backwards?

by Eran » Post

You can set a negative animation frame speed, I just tried it out.
So

Code: Select all

object:set_animation({x = 1, y = 10}, -n)

Termos
Member
Posts: 372
Joined: Sun Dec 16, 2018 12:50

Re: set_animation() running backwards?

by Termos » Post

Eran wrote:You can set a negative animation frame speed, I just tried it out.
Tried that too, animation just did not run. I'll check again.

Eran
Member
Posts: 123
Joined: Fri May 03, 2019 16:46

Re: set_animation() running backwards?

by Eran » Post

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
Attachments
dwarf_characters.tar.gz
(43.62 KiB) Downloaded 5 times

Termos
Member
Posts: 372
Joined: Sun Dec 16, 2018 12:50

Re: set_animation() running backwards?

by Termos » Post

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.

Termos
Member
Posts: 372
Joined: Sun Dec 16, 2018 12:50

Re: set_animation() running backwards?

by Termos » Post

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:

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
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.

User avatar
runs
Member
Posts: 2060
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: set_animation() running backwards?

by runs » Post

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:

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
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.
So make a bug request.
🤑 Patreon |Minetest Element Chat | 👧 Samantha | ⛏️ Juanchi Game | 🐱 Petz

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest