State Impact with Delay

GrillMaster

Member
Hey @Justin , I just discovered a potential bug.

Clean project, default character + abilities. Working with the demo grenade - more specifically, the StateImpact Module inside the Explosion prefab.

When you set StateImpact in the Impact Action Group, the state fires correctly and turns off correctly - the State is being set on the affected character, any component.

Now add a small delay to the SimpleDamage module - now when the State is set, it does not time out at all. This happens only with the SimpleDamage module - reordering the list has no effect. I wanted to set a state before applying damage, because I need to make sure some components are not listening when physics is applied.
 

Attachments

  • 1756768018888.png
    1756768018888.png
    56.6 KB · Views: 2
  • 1756768094357.png
    1756768094357.png
    70.6 KB · Views: 1
  • 1756768953469.png
    1756768953469.png
    37.2 KB · Views: 2
  • 1756769014685.png
    1756769014685.png
    87.2 KB · Views: 2
The explosion gets destroyed immediately so the delay no longer occurs. If you want to set the state before applying the damage you can move the Simple Damage module last within the list.
 
Found a potential fix - can you please confirm? It seems to work alright on my end, no telling if it breaks some other hidden system though.

Inside SimpleDamage.cs -> public class StateImpact --> OnImpactInternal(ImpactCallbackContext ctx)

Original:
if (!string.IsNullOrEmpty(stateName)) {
var characterLocomotion = impactData.ImpactGameObject.GetCachedParentComponent<UltimateCharacterLocomotion>();

StateManager.SetState(characterLocomotion != null ? characterLocomotion.gameObject : impactData.ImpactGameObject, stateName, true);

if (disabletimer != -1) {
StateManager.DeactivateStateTimer(impactData.ImpactGameObject, stateName, disabletimer);
}
}

Proposal:
if (!string.IsNullOrEmpty(stateName)) {
var characterLocomotion = impactData.ImpactGameObject.GetCachedParentComponent<UltimateCharacterLocomotion>();

var stateTarget = characterLocomotion != null
? characterLocomotion.gameObject
: impactData.ImpactGameObject;

StateManager.SetState(stateTarget, stateName, true);

if (disabletimer != -1) {
StateManager.DeactivateStateTimer(stateTarget, stateName, disabletimer);
}
}

Edit: Removed earlier posts for brevity. Colored targeted edits for visibility
 
Last edited:
Back
Top