Created
January 4, 2024 10:10
-
-
Save flushpot1125/275dc684cb1f8f6b97ce9e2486ec7902 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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