friction and sand pit
This commit is contained in:
parent
08712cf22c
commit
77ef1dee48
5 changed files with 81 additions and 35 deletions
30
objects/sand_pit.gd
Normal file
30
objects/sand_pit.gd
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue