Created
March 21, 2016 17:53
-
-
Save YeOldeDM/e45c698a3081d0cf1100 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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