generated from krampus/template-godot4
16 lines
539 B
GDScript
16 lines
539 B
GDScript
class_name SurfaceSnapTool extends Tool
|
|
## A Tool whose HUD component snaps to a surface
|
|
|
|
@onready var raycast: RayCast3D = %Raycast
|
|
@onready var resting_position: Marker3D = %RestingPosition
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
hud_tool.global_basis = global_basis
|
|
|
|
var weight := 1 - exp(-hud_accel * delta)
|
|
var target_position := resting_position.global_position
|
|
if raycast.is_colliding():
|
|
target_position = raycast.get_collision_point()
|
|
hud_tool.global_position = hud_tool.global_position.lerp(target_position, weight)
|