make player stop when hitting flor
This commit is contained in:
@@ -49,7 +49,5 @@ visible = false
|
||||
top_level = true
|
||||
script = ExtResource("6_tuyoq")
|
||||
_steps = 180
|
||||
_do_collisions = null
|
||||
_wall_bounce_velocity_loss = null
|
||||
_line_color = Color(1, 1, 0, 1)
|
||||
metadata/_custom_type_script = "uid://ceyu5der8j8gq"
|
||||
|
||||
@@ -70,11 +70,14 @@ static func process_movement(
|
||||
static func process_collision(
|
||||
new_velocity: Vector2,
|
||||
slide_velocity: Vector2,
|
||||
on_floor: bool,
|
||||
on_ceiling: bool,
|
||||
on_wall: bool,
|
||||
wall_bounce_velocity_loss: float,
|
||||
) -> Vector2:
|
||||
if not on_ceiling:
|
||||
if on_floor:
|
||||
slide_velocity.x = 0
|
||||
if on_ceiling:
|
||||
slide_velocity.x *= wall_bounce_velocity_loss
|
||||
if on_wall:
|
||||
slide_velocity.x = -new_velocity.x * wall_bounce_velocity_loss
|
||||
@@ -146,6 +149,7 @@ func _physics_process(delta: float) -> void:
|
||||
velocity = process_collision(
|
||||
new_velocity,
|
||||
velocity,
|
||||
on_floor,
|
||||
on_ceiling,
|
||||
on_wall,
|
||||
_wall_bounce_velocity_loss,
|
||||
|
||||
@@ -252,6 +252,7 @@ func _draw() -> void:
|
||||
. process_collision(
|
||||
velocity,
|
||||
velocity,
|
||||
is_hitting_floor,
|
||||
is_hitting_ceiling,
|
||||
is_hitting_wall,
|
||||
_wall_bounce_velocity_loss,
|
||||
|
||||
Reference in New Issue
Block a user