TombEngine
TombEngine copied to clipboard
Calling Moveable:Enable() on an already enabled moveable seems to reset it now
There's a behavior that changed and I don't know if it's expected.
Previously, I had a setup where I was checking some conditions in OnControlPhase()
, and if these conditions were true, i wanted to activate an Animating like that:
local Ringer = GetMoveableByName("ringer")
Ringer:Enable()
Ringer:SetState(1)
print("Ringer should spin now | State = `"..Ringer:GetState().."` | Animation = `"..Ringer:GetAnim().."` | Frame = `"..Ringer:GetFrame().."`")
Animation 0 is a static looping 1-frame animation. It has a State change that leads to animation 1 when the object gets state 1. In short, this code would simply activate the object and make it switch instantly to animation 1 (which is an actual spinning animation).
I then stop/restart the animation depending on these conditions by switching the State to 0 and 1 respectively (and the animations will follow accordingly, based on the state changes I've set up).
The setup is done this way because I want the animations to decide when it can actually stop, not the code (else there would be visible snaps). This was working fine before.
The output:
[2023-Jan-15 22:05:32] [info] Ringer should spin now | State = `0` | Animation = `0` | Frame = `0`
[2023-Jan-15 22:05:33] [info] Ringer should spin now | State = `1` | Animation = `1` | Frame = `0`
[2023-Jan-15 22:05:33] [info] Ringer should spin now | State = `1` | Animation = `1` | Frame = `1`
[2023-Jan-15 22:05:33] [info] Ringer should spin now | State = `1` | Animation = `1` | Frame = `2`
[2023-Jan-15 22:05:33] [info] Ringer should spin now | State = `1` | Animation = `1` | Frame = `3`
[2023-Jan-15 22:05:33] [info] Ringer should spin now | State = `1` | Animation = `1` | Frame = `4`
Now, I didn't change anything to this setup recently, but I updated TE/TEN yesterday.
For the record, changes were done to what Moveable:Enable()
and Moveable:Disable()
should do.
And now this setup is not working as is anymore. When I launched the game and this script ran, the object was staying at animation 0, state 0 and I couldn't understand why.
[2023-Jan-15 21:37:23] [info] Ringer should spin now | State = `0` | Animation = `0` | Frame = `0`
[2023-Jan-15 21:37:23] [info] Ringer should spin now | State = `0` | Animation = `0` | Frame = `0`
[2023-Jan-15 21:37:23] [info] Ringer should spin now | State = `0` | Animation = `0` | Frame = `0`
[2023-Jan-15 21:37:23] [info] Ringer should spin now | State = `0` | Animation = `0` | Frame = `0`
[2023-Jan-15 21:37:24] [info] Ringer should spin now | State = `0` | Animation = `0` | Frame = `0`
[2023-Jan-15 21:37:24] [info] Ringer should spin now | State = `0` | Animation = `0` | Frame = `0`
I changed the code to this, and now it works again:
local Ringer = GetMoveableByName("ringer")
if not Ringer:GetActive() then
Ringer:Enable()
end
Ringer:SetState(1)
print("Ringer should spin now | State = `"..Ringer:GetState().."` | Animation = `"..Ringer:GetAnim().."` | Frame = `"..Ringer:GetFrame().."`")
It seems like Enable()
kept resetting the animating to its original state.
I don't know if this is an actual issue, or just a design consequence we have to live with, and we can just add this check to avoid re-enabling the moveable when it's already active.
But it was an odd change, because in the past (even in OG engines), re-enabling an animating repeatedly would just have no effect if the object was already active.
I have looked at the code and I can't say why such issue happens in your case. @hispidence should look into it, but from the first sight, triggering should not happen again after item was initialized, as there ARE checks for item status and activation mask.