Closed RychuP closed 1 week ago
Thanks for reporting this. The reason this is happening is InterpolateToState method relies on internal velocity variables to work. If a variable (such as TextureScale) doesn't have a velocity variable, then it won't apply in this method. This is a bad implementation because it requires understanding what does and doesn't have velocity variables instead of it "just working".
Instead, the TweenerManager provides an interpolation method which will work for all variables. Here's what your code might look like using that:
public void StartInvulnerability()
{
_invulnerabilityStartTime = TimeManager.CurrentScreenTime;
// disable damage receiving
IsDamageReceivingEnabled = false;
// create a start instruction
CurrentInvulnerabilityState = Invulnerability.Visible;
//var startInstr = InterpolateToState(Invulnerability.Hidden, InvulnerabilityTimeAfterDamage);
_=TweenerManager.Self.TweenAsync(this,
(value) => InterpolateBetween(Invulnerability.Visible, Invulnerability.Hidden, value),
0,
1,
(float)InvulnerabilityTimeAfterDamage);
// create a stop instruction
var stopInstr = new DelegateInstruction(StopInvulnerability)
{
TimeToExecute = TimeManager.CurrentScreenTime + InvulnerabilityTimeAfterDamage
};
Instructions.Add(stopInstr);
}
To help address this for future users, here's the changes I've made:
For more information on the alternative code using TweenerManager, see https://docs.flatredball.com/flatredball/api/stateinterpolationplugin/tweenermanager
The docs here are fairly basic, so if you would like any more info please let me know and I can add more.
In my particular example I was interpolating to an FRB state using InterpolateToState method. The states contain three variables: two floats and a bool. One of the floats and the bool interpolated as expected. The Sprite Texture Scale remained unchanged during interpolation. Example can be found here.