Facepunch / sbox-issues

181 stars 12 forks source link

Auto-Ducking Offset Problem in PlayerController Component #7469

Open gabrielgilvan opened 1 week ago

gabrielgilvan commented 1 week ago

Describe the bug

The UpdateHeadroom function in the PlayerController component is incorrectly calculating the headroom offset. This issue causes the player to start ducking even when the ceiling or an overhead object is not close. For example, passing through a doorway incorrectly triggers the ducking behavior.

Image

To Reproduce

  1. Set up the player with default PlayerController values.
  2. Place an object with collision above the player.
  3. Move the object up/down and observe that the duck parameter starts to change even when the object is not close to the player's head.

Expected behavior

The player should only duck when the object above is within a valid proximity.

Media/Files

Image

Additional context

No response

garrynewman commented 1 week ago

Code looks correct to me. It's tracing the body aabb upwards by 100 units, then returning the distance it got.

Is your problem more that he's reacting to the low ceiling too early? At the moment it starts reacting if something is 50 units above the head, we should bring that down a bit? 10 maybe?

gabrielgilvan commented 1 week ago

50 units looks way better but why not stick an variable to that ?

Image