Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created January 4, 2024 10:10
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 flushpot1125/275dc684cb1f8f6b97ce9e2486ec7902 to your computer and use it in GitHub Desktop.
Save flushpot1125/275dc684cb1f8f6b97ce9e2486ec7902 to your computer and use it in GitHub Desktop.
func _integrate_forces(state):
var delta = state.get_step()
var lv = state.get_linear_velocity()
var g = state.get_total_gravity()
# get_total_gravity returns zero for the first few frames, leading to errors.
if g == Vector3.ZERO:
g = gravity
lv += g * delta # Apply gravity.
var up = -g.normalized()
if dying:
state.set_linear_velocity(lv)
return
for i in range(state.get_contact_count()):
var cc = state.get_contact_collider_object(i)
var dp = state.get_contact_local_normal(i)
if cc:
if cc is preload("res://player/bullet/bullet.gd") and cc.enabled:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment