Skip to content

Player doesn't leave sliding state  #416

Open
@tfloreste

Description

@tfloreste

Short description
When jumping in certain rock formations, sometimes the player doesn't finish sliding. When that happens the directional movement becomes unresponsive (jumping sometimes does work to help the player reach the ground, but apparently not always).

It seems to be the same problem described on issue #350
The difference though is that I noticed it happening when the player is not surrounded by rocks (see video below)

Expected behavior
The player finishes sliding and returns to Idle state

To Reproduce
Steps to reproduce the behavior:

  1. Play the "TestingGround" scene
  2. Go to the rock formation at position (-51.1, 0, -14.81)
  3. Jump at it as shown in the video below
  4. Sometimes the player will get stuck and not finish sliding

Notes

  • The video below shows the problem happening. Note that the State Machine doesn't leave the sliding state
SlideBug.mp4
  • Even though I used a specific rock as an example, the problem happened to me in other locations. Including in the Beach location after I built the game

  • This problem doesn't always happen. It seems to be happening quite randomly to me

  • I did a little debugging and the problem seems to be related to high frame rates (SEE EDIT BELOW). In the screenshot of the console below (taken during the video above) we can see that:

    • The first line (SLIDE ACTION VELOCITY: ....) shows the velocity vector calculated in SlideActionSO.cs. It has a negative value in the y component, which seems to be correct. This velocity is the one that is set in the movementValue vector of the Protagonist script and is then used in the ApplyMovementValueSO.cs to apply the movement.

    • The second line (Movement Vector: ...) shows the value of the movementValue vector the ApplyMovementValueSO.cs script uses. It has the same value calculated in the SldeActionSO.cs, which is also correct

    • The third line (deltaTime: ....) shows the Time.deltaTime value used as a multiplier in the ApplyMovementValueSO.cs script

    • The fourth line (Moving towards: ....) shows the resulting product between movementValue and Time.deltaTime. The result has the y component equal to zero, which is not correct (in this case, the expected value should be around -0,0016). I imagine this is happening because the Time.deltaTime is a very small number and the result is rounded to 0

SlideBug

EDIT

After a little research, I found the problem was (probably) not related to frame rates. It seems that printing a Vector3 will automatically round its value but it doesn't mean the "real" value was rounded.

I did more testing and even when the y component of the movementValue vector is not zero the problem still happens (see video below. This time I recorded the console too).

bugSlide2.mp4

I also added code to debug the CollisionFlags returned by the CharacterController.Move method (the same code described in this link). In the image below the "Move towards" vector is not zero, but when that screenshot was taken the player was stuck in the air (second video). Also, it seems the controller is only detecting a collision below the player. Can that collision be preventing the player from falling in this case?

slideBug2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug (minor)The game could potentially ship with this bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions