generated from krampus/template-godot4
23 lines
587 B
GDScript3
23 lines
587 B
GDScript3
|
class_name WorldSticker extends Sprayable
|
||
|
|
||
|
@onready var decal: Decal = %Decal
|
||
|
|
||
|
|
||
|
func _hit() -> void:
|
||
|
# Remove on hit
|
||
|
queue_free()
|
||
|
|
||
|
|
||
|
## Place this sticker at a given point, aligned to the given normal, with the given texture.
|
||
|
func place(texture: Texture2D, point: Vector3, normal: Vector3, src_up: Vector3) -> void:
|
||
|
decal.texture_albedo = texture
|
||
|
global_position = point
|
||
|
|
||
|
# Build basis
|
||
|
var up := normal
|
||
|
var right := up.cross(src_up).normalized()
|
||
|
var forward := -right.cross(up).normalized()
|
||
|
global_basis = Basis(right, up, forward)
|
||
|
|
||
|
# TODO handle serialization & deserialization
|