Page 1 of 1
[0.17.69] Idle animations are drawn, but not animated.
Posted: Fri Oct 11, 2019 10:36 am
by JoeyDP
Crafting machine prototypes have an idle animation (
https://wiki.factorio.com/Prototype/Cra ... _animation). As I understand it, this animation should be used when the machine is in an idle state. However it appears the "animation" is only rendered, but not animated as one would expect. I would like to have idle animations in my mod
https://mods.factorio.com/mod/better-air-filtering.
The only vanilla entity that I found using this feature is the centrifuge. It strangely both defines an animation and an idle animation, but then sets the flag "always_use_idle_animatio", making the former obsolete if I understand correctly. (See:
https://github.com/wube/factorio-data/b ... .lua#L9774)
It is unclear whether centrifuges are supposed to have an animation when idle and this feature is broken, or if the "idle_animation" has a different purpose altogether.
Thanks in advance for clarifying.
Re: [0.17.69] Idle animations are drawn, but not animated.
Posted: Fri Oct 11, 2019 11:38 am
by posila
Centrifuges and idle_animation work as intended. The idle animation should match animation (it is checked they have the same frame count), but show the machine in idle state. In case of centrifuge - working centrifuge has green glow, idle doesn't have green glow (this could be achieved through working visualizations in 0.17, but they didn't used to use the same frame counter as the main animation so it was not possible to sync working visualization animation with main animation). In addition, the green glow is just an additive overlay that is supposed to be draw over the idle state, therefore always_use_idle_animation = true is used.
Re: [0.17.69] Idle animations are drawn, but not animated.
Posted: Fri Oct 11, 2019 12:50 pm
by JoeyDP
Thank you for taking the time to explain this mechanic. After taking a look at the actual sprites, it is indeed clear that idle animations can be used like you described.
Then I propose a simple addition to provide the mechanic I had in mind: a property animation_speed_when_idle that is set to 0 by default. This would allow for entities with an animation when they are not performing an active task. A good example could be turrets looking around while no enemies are nearby.
Of course this is just a suggestion and I don't have all the technical details worked out. I don't know how well this would fit with the mentality of the game and if there are enough use cases to make it worthwhile. I would love to hear your opinion on this idea.
Re: [0.17.69] Idle animations are drawn, but not animated.
Posted: Fri Oct 11, 2019 3:05 pm
by JoeyDP
Just found this:
viewtopic.php?t=58377 (idea of turret idle animation).
Re: [0.17.69] Idle animations are drawn, but not animated.
Posted: Fri Oct 11, 2019 3:35 pm
by Honktown
JoeyDP wrote: ↑Fri Oct 11, 2019 12:50 pm
A good example could be turrets looking around while no enemies are nearby.
Graphical animations are distinct from actual behavior. Turrets do have an orientation, so a graphical animation would sorta corrupt this (it would go from mid-animation back to where it was resting and pointed in a cardinal direction when it had to shoot).
Perhaps you can implement a function, that if a turret is not firing, it has a percent chance of "sitting up" and rotating left or right? A challenge is you either need a timer for each turret, or a global one that rams through every gun turret nearby and triggers the "animation" feature. Contrast machines that can instantly know when they're idle and may animate differently (when they stop working). I didn't think about that you could animate turrets you can see, which would reduce the performance needed. A detector could look for turrets within radius of the player to animate (i.e. what's nearby vs what you can see, very different problems).
Edit: I had an even better, and probably easier idea for turrets. Spawn an invisible, uncollidable, unshootable enemy, with a lifetime of 3-6 seconds. The turrets would wake-up, begin tracking something, and then a few seconds later go back to rest. If the enemy didn't move they'd look at one spot, and if the enemy could move you could have it chase the player, so it looks like the turrets are tracking the player.
Sorry, didn't see your mod link and that the question is better fit for machines.