Trying to transition between abilities knocked down to laying down.

zoicelols

Member
I have MyDamageVisualization subclassing damage visualization. Through this there are 4 different directions to be knocked down based on where the character is hit and if they were hit with at least 15 or higher damage, otherwise the normal damage visualization animations play. Right now I have the animator transitioning from knocked down to laying down and then to MyRevive to get back up. Correct me if im wrong. I believe I need to create a laying down ability that MyRevive can pull the character out of. Maybe there is a better way?

What would be the best way to transition MyDamageVisualization knocked down animation to a laying down ability? Not quite sure what I would need to put in the script.
 
It does sound like you'll want a new ability to handle this situation. You could have your new ability subscribe to the OnDamage event similar to what the DamageVisualization class does, and then have it play an animation based on the hit amount. This way the UI and ability are independent.
 
Okay cool so the direction of where I fall will match where i get knocked down.

How do I specify what will determine when the transition from knocked down to laying down will start? Like if knocked down is complete, then start laying down.
 
You could chain the second ability to be started by the first ability, i.e. in your first ability you'd call the second ability with TryStartAbility. You could put this in the AbilityStopped method of the first ability, or maybe you want to time it with some other event, in which case an animation event might be more suited to what you need.
 
I added this code to MyDamageVisualization ability

Code:
[SerializeField] protected GameObject m_Character;

protected override void AbilityStopped(bool force)
    {

        base.AbilityStopped(force);

        var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();
        var downedAbility = characterLocomotion.GetAbility<Downed>();

        characterLocomotion.TryStartAbility(downedAbility);

       
    }

When my character is knocked down(MyDamageVisualization) I get this error and my Downed ability doesn't activate at all.

1605339212053.png

1605339319535.png
 
Last edited:
Which line is it referring to (148)? I'm guessing that it's not able to find the Downed ability. The ability name you pass in to GetAbility should be the same as the name of the component, e.g. Downed.cs.
 
Line 148 is actually

var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();

My Downed ability is Downed.cs
 
In that case, I'd assume you don't have m_Character set to a reference of the character gameobject, or it's losing its reference somehow (e.g. it's a prefab or you're switching scenes). If you do Debug.Log(m_Character), then Debug.Log(m_Character.GetComponent<UltimateCharacterLocomotion), you can see if it's the character or the UCL component that's returning null.
 
I checked with the debugs and the m_Character turns up null while the UCL doesn't.
I thought I AM referencing the character gameobject with this line while also having the MyDamageVisualization ability that I am editing on the character?

I am not switching scenes.
Also what do you mean by prefab makes it lose its reference? I did use a prefab model to create the character in the scene that I am using.


Code:
[SerializeField] protected GameObject m_Character;
 
Within the ability you should use m_GameObject instead of assigning your own reference if you just want a reference to the local character GameObject.
 
Top