Skip to content

Instantly share code, notes, and snippets.

@YeOldeDM
Created March 21, 2016 17:53
Show Gist options
  • Save YeOldeDM/e45c698a3081d0cf1100 to your computer and use it in GitHub Desktop.
Save YeOldeDM/e45c698a3081d0cf1100 to your computer and use it in GitHub Desktop.
func _integrate_forces(state):
var direction = get_linear_velocity()
var step = state.get_step()
for i in range(state.get_contact_count()):
var pos = get_pos()
var col = state.get_contact_collider_object(i)
var norm = state.get_contact_local_normal(i)
if col:
if col extends player_class:
col.get_hit(self,2)
if get_node('up_ray').is_colliding() or pos.y <= 0:
direction.y = SPEED
if get_node('down_ray').is_colliding() or pos.y >= 88:
direction.y = -SPEED
if get_node('left_ray').is_colliding() or pos.x <= 0:
direction.x = SPEED
if get_node('right_ray').is_colliding() or pos.x >= 128:
direction.x = -SPEED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment