summaryrefslogtreecommitdiffhomepage
path: root/Player.gd
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-01-21 20:36:39 -0500
committerrealtradam <[email protected]>2021-01-21 20:36:39 -0500
commit9ec667679fddcfbb096a31801052b27667c9a2eb (patch)
treef08bd51c4043fccc5024b685f6f0ffbe55827e6d /Player.gd
parent32528712befef39670f2ef30974e33fa291cebe3 (diff)
downloadE-C-Kai-master.tar.gz
E-C-Kai-master.zip
added physics interaction with playerHEADmaster
Diffstat (limited to 'Player.gd')
-rw-r--r--Player.gd9
1 files changed, 7 insertions, 2 deletions
diff --git a/Player.gd b/Player.gd
index 254aef3..3196dab 100644
--- a/Player.gd
+++ b/Player.gd
@@ -47,12 +47,17 @@ func _physics_process(delta):
if self.is_on_ceiling():
velocity.y = 1
-
+
# We don't need to multiply velocity by delta because "move_and_slide" already takes delta time into account.
# The second parameter of "move_and_slide" is the normal pointing up.
# In the case of a 2D platformer, in Godot, upward is negative y, which translates to -1 as a normal.
- move_and_slide(velocity, Vector2(0, -1))
+ move_and_slide(velocity, Vector2.UP, false, 4, PI/4, false)
+ for index in get_slide_count():
+ var collision = get_slide_collision(index)
+ if collision.collider.is_in_group("bodies"):
+ print(collision.normal)
+ collision.collider.apply_central_impulse(-collision.normal * velocity.length() * 0.3)
func respawn():
position = respawn_position