Possibly better to use instance ID of collider rather than RID

This commit is contained in:
Niamh Nikali 2025-07-12 10:59:35 -06:00
parent f425461a1e
commit d9fe33311f

View File

@ -6,7 +6,7 @@ const NORMAL_OFFSET = 0.05
@export var parent_tool: Spray
# Currently gunking
var gunk_rid: RID
var gunk_id: int
var gunkable: Gunkable
@onready var laser_dust: GPUParticles3D = %LaserDust
@ -21,9 +21,12 @@ func _process(_delta: float) -> void:
if c is Node3D:
(c as Node3D).global_position = child_pos
var new_gunk_rid: RID = get_collider_rid()
if new_gunk_rid != gunk_rid:
gunk_rid = new_gunk_rid
var new_gunk_id: int = 0
var collider: Object = get_collider()
if collider:
new_gunk_id = collider.get_instance_id()
if new_gunk_id != gunk_id:
gunk_id = new_gunk_id
if gunkable:
# Disconnect old signals to avoid emitting from previous node and accumulating connections
if gunkable.painted_at_point.is_connected(gunk_dust._on_gunkable_painted_at_point):
@ -34,7 +37,7 @@ func _process(_delta: float) -> void:
gunkable.clear_total_updated.disconnect(
gunk_dust._on_gunkable_clear_total_updated
)
gunkable = Gunkable.get_component(get_collider())
gunkable = Gunkable.get_component(collider)
if gunkable:
# Connect signals of new gunkable to our gunk dust
if !gunkable.painted_at_point.is_connected(gunk_dust._on_gunkable_painted_at_point):