Skip to content

Instantly share code, notes, and snippets.

@rosskarchner
Last active June 29, 2022 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosskarchner/d651abe7fb3c507e0ff0ba17f25b1155 to your computer and use it in GitHub Desktop.
Save rosskarchner/d651abe7fb3c507e0ff0ba17f25b1155 to your computer and use it in GitHub Desktop.
func _integrate_forces(state):
# enforce min and max speed
# based on: https://godotengine.org/qa/44040/how-to-set-a-max-speed-of-a-rigidbody2d?show=44086#c44086
# no, I don't totally understand the math
state.linear_velocity=state.linear_velocity.normalized()*clamp(state.linear_velocity.length(), 700, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment