Character 'Max Fall speed' works incorrect if the character gravity is > 0

mirec313 4 months ago in Game Creator updated by Marti (Lead Developer) 3 months ago 2

Hi, I'm trying swimming tutorial


with a modification - when I press a button (space) then player gravity will set to a +9.81 and max fall speed to a +2

But then a character is moving upwards much faster than when he moving downwards with gravity -9.81 and max fall speed -2

It seems the problem is that max fall speed in not applied correctly if gravity is > 0

There is check in the file CharacterLocomotion.cs at the end of function 'UpdateVerticalSpeed' which does not works for positive values:

this.verticalSpeed = Mathf.Max(this.verticalSpeed, this.maxFallSpeed);

Also there is another small problem:

If the gravity is negative (-9.81) and the max fall speed is positive (+100), character is moving upwards although the gravity is negative.

I fixed both problems - replacing test with: 

if (this.gravity <= 0)
     this.verticalSpeed = Mathf.Max(this.verticalSpeed, -Mathf.Abs(this.maxFallSpeed));
     this.verticalSpeed = Mathf.Min(this.verticalSpeed, Mathf.Abs(this.maxFallSpeed));

Unity version:
Game Creator version:
Under review

Yeah, the fall speed should probably be clamped by magnitude. I'm opening a ticket to assess this. Thanks!


This issue has been addressed and will come with the next release. I'm closing the ticket, but if you experience any issues after the update, feel free to write them below. Cheers!