Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gravity collision jitter workaround; MIN_GRAVITY_SPEED #168

Merged
merged 1 commit into from
May 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/world/turbo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ extends Customer3D
Script for manipulating the player-controlled character 'Turbo' in the 3D overworld.
"""

# If acceleration via gravity makes our vertical momentum something small like -6, there's a risk we won't actually
# collide with the surface we're sitting on which causes causing an unpleasant jitter effect.
#
# This is our minimum vertical velocity. Any non-zero values smaller than this will be scaled up.
const MIN_GRAVITY_SPEED = 10.0

# Number from [0.0, 1.0] which determines how quickly Turbo slows down
const FRICTION := 0.15

Expand Down Expand Up @@ -197,6 +203,11 @@ func _update_camera_target() -> void:

func _apply_gravity(delta: float) -> void:
_velocity += Vector3.DOWN * GRAVITY * delta

# If acceleration via gravity makes our momentum something small like -6, there's a risk we won't actually collide
# with the surface we're sitting on which causes causing an unpleasant jitter effect.
if _velocity.y < 0.0 and _velocity.y > -MIN_GRAVITY_SPEED:
_velocity.y = -MIN_GRAVITY_SPEED


func _apply_friction() -> void:
Expand Down