[Bug] Abilities not setting gravity (2020.3.11f1)

DavidC

Member
A bit of background. I've been working on abilities for awhile now, and I just have been getting endless amounts of grief with them. From things like disabling gravity not working (when it works on every other ability in the demo scene), to whole fields not showing up, to input not being registered, etc.

1. UCC Vanilla Install (absolutely nothing else installed in a clean project)
2. 2020.3.11f1 LTS
3. Abilities fail to serialize properly. Input won't be registered, abilities will fail to activate, fields in the abilities being changed fails to reflect in game mode.
4. Get a fresh copy of UCC Vanilla Installed. Turn off "use gravity" on Jump. Open demo scene, verify it's working (without gravity). Exit playmode. Disable Jump Ability (uncheck). Save.
A) Start a new ability script called Jump1. Copy over code from Jump. Make sure to keep class name Jump1. Add the class attribute tag
Code:
[DefaultUseGravity(AbilityBoolOverride.False)]
Save script. In editor, add Jump1 ability. Look at fields, sometimes fields will fail to load entirely, other times they load, BUT... now run the scene. Try jumping (without gravity). See difference? Exiting and restarting unity seems to have no effect.

B) As before with a clean project. Now completely exit out of Unity and VS. Go to the file in Explorer. Duplicate the Jump.cs script. Rename it Jump1.cs. Open it with notepad, change class name to Jump1, add attribute tag as before. Save. Load up unity. Test Jump1 as befpre. In my trial, this worked without issue.

It also seems that once an ability is serialized incorrectly, that nothing you do (including quitting and restarting both Unity and VS) will fix it. This includes having removed and re added it to the abilities on Nolan

I've encountered numerous problems, but this seems to be the most reliable way to recreate.

5. No Error Message

As a question, what version of Unity are you working in for making Abilities? I would like to switch to that for making abilities in for now.
 
Last edited:

Justin

Administrator
Staff member
Turn off "use gravity" on Jump.
Within the inspector? Or the attribute?

As a question, what version of Unity are you working in for making Abilities? I would like to switch to that for making abilities in for now.
Most of the abilities were built with Unity 5.6 - 2017.4, so versions prior to the currently supported version. I have created abilities in 2018.4 for swimming and am currently using 2019.4 for climbing and have not noticed any issues.
 

Justin

Administrator
Staff member
Thanks, I think that I know what is happening -

Save script. In editor, add Jump1 ability. Look at fields, sometimes fields will fail to load entirely, other times they load, BUT... now run the scene. Try jumping (without gravity). See difference? Exiting and restarting unity seems to have no effect.
When I did this in 2020.3 the fields loaded ok but the character did not stay floating. The reason for this is because when you add the ability it adds it to the end of the list and the Fall ability has a higher priority. Jump should have a higher priority than Fall so when I moved Jump1 up it worked the same as the original Jump.
 

DavidC

Member
Thanks, I think that I know what is happening -


When I did this in 2020.3 the fields loaded ok but the character did not stay floating. The reason for this is because when you add the ability it adds it to the end of the list and the Fall ability has a higher priority. Jump should have a higher priority than Fall so when I moved Jump1 up it worked the same as the original Jump.
Hmm. I'm getting strange behavior, still. Sometimes I have no problem. Here's two videos.

In this video, in 2019.4, fresh project, I delete every ability, then in the inspector, I turn gravity off for the Jump ability. By turning the stop type to manual, this one is fixed...


In this video, in 2020.3 I have an ability very similar to Jump (at this point, it just gives some upward force when started and should be disabling gravity). I even went so far as to comment out every line of code that wasn't absolutely necessary while troubleshooting. Changing the stop type to manual doesn't fix this one. Manually unchecking "Use Gravity" in the physics section fixes this.


Btw, I'm focusing on gravity because it's the most obvious problem/recreatable I've encountered. I've seen some other weird stuff, like when I added another Jump (as instructions above), it only populated the base ability and not the jump ability. I had an ability that would get deleted out of the list of abilities in inspector when you hit play (and then it would cause an error since it no longer existed). Maybe the correlation here is that if you change a lot of things (edit the script a few times and/or change a lot of variables in the ability in the inspector), you start seeing the problems more.
 

DavidC

Member
If the ability is working as expected (disabled gravity by default), flip it to the opposite in the inspector during edit time, then run again, and it doesn't update (gravity is still disabled despite now being enabled).

I'm starting to wonder if the array of abilities in the editor desyncs with the values. I can try testing in the morning.
 
Last edited:

Justin

Administrator
Staff member
In your first video the reason why gravity is being applied is because your stop type of automatic is stopping the jump ability immediately after it is in the air. Every frame CanStopAbility is checked with an automatic stop type and as soon as that returns true the ability will stop.

In your second video the force is being added when you enable the ability because of the automatic start type. The ability is starting, applying the force, and then stopping.
 

DavidC

Member
I have new reproduction steps for you (with files) for the gravity bool.
1. Clean scene, just a plane and a Nolan setup to move (for some reason demo scene was causing other weirdness)
2. Remove any other abilities, especially fall.
3. Use two minimum code required abilities, provided below. Deactivate these abilities before starting the scene, and activate them in the inspector. The expected result of both should be "Jump and hover."
"Just Default Use Gravity" uses the attribute tag.
"Direct2Variable" sets m_CharacterLocomotion.UseGravity to false/true as activated/deactivated. Please note I included the same Debug.Log in each. The expected value of both should be "false."

I think the other problems I was having at the same time was just Unity & VS having issues. I had heard 2020 is less stable than 2019, and that seems to be the case, here.
 

Attachments

  • JustDefaultUseGravity.cs
    995 bytes · Views: 1
  • Direct2Variable.cs
    1.1 KB · Views: 3

Justin

Administrator
Staff member
I created a new character and didn't add any abilities at besides your two abilities. I then added your abilities and disabled both of them.

When I enabled Direct 2 Variable the gravity was correctly set to disabled.

When I enabled Just Default Use Gravity it was set to enabled. The reason for this is because that attribute is set within AbilityStarted and your class is not calling the base method. When I called the base AbilityStarted method within your class the gravity was not applied.
 

DavidC

Member
I created a new character and didn't add any abilities at besides your two abilities. I then added your abilities and disabled both of them.

When I enabled Direct 2 Variable the gravity was correctly set to disabled.

When I enabled Just Default Use Gravity it was set to enabled. The reason for this is because that attribute is set within AbilityStarted and your class is not calling the base method. When I called the base AbilityStarted method within your class the gravity was not applied.
Oh, that's an embarrassing oversight. Well thank you very much for helping me solve this one!
 
Top