friction and sand pit

This commit is contained in:
Haze Weathers 2025-02-22 21:12:25 -05:00
parent 08712cf22c
commit 77ef1dee48
5 changed files with 81 additions and 35 deletions

30
objects/sand_pit.gd Normal file
View file

@ -0,0 +1,30 @@
extends CSGPolygon3D
@export var friction: float
@export_group("Node References")
@export var collision_polygon: CollisionPolygon3D
var _players: Array[Player] = []
func _ready() -> void:
collision_polygon.polygon = polygon
collision_polygon.depth = depth
func _physics_process(delta: float) -> void:
for player in _players:
player.velocity = lerp(player.velocity, Vector3.ZERO, friction * delta)
func _on_body_entered(body: Node3D) -> void:
if body is Player:
_players.append(body)
func _on_body_exited(body: Node3D) -> void:
if body is Player:
_players.erase(body)