diff options
| author | realtradam <[email protected]> | 2021-01-21 20:36:39 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-01-21 20:36:39 -0500 |
| commit | 9ec667679fddcfbb096a31801052b27667c9a2eb (patch) | |
| tree | f08bd51c4043fccc5024b685f6f0ffbe55827e6d /Player.gd | |
| parent | 32528712befef39670f2ef30974e33fa291cebe3 (diff) | |
| download | E-C-Kai-9ec667679fddcfbb096a31801052b27667c9a2eb.tar.gz E-C-Kai-9ec667679fddcfbb096a31801052b27667c9a2eb.zip | |
Diffstat (limited to 'Player.gd')
| -rw-r--r-- | Player.gd | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 |
