generated from krampus/template-godot4
Possibly better to use instance ID of collider rather than RID
This commit is contained in:
parent
f425461a1e
commit
d9fe33311f
@ -6,7 +6,7 @@ const NORMAL_OFFSET = 0.05
|
|||||||
@export var parent_tool: Spray
|
@export var parent_tool: Spray
|
||||||
|
|
||||||
# Currently gunking
|
# Currently gunking
|
||||||
var gunk_rid: RID
|
var gunk_id: int
|
||||||
var gunkable: Gunkable
|
var gunkable: Gunkable
|
||||||
|
|
||||||
@onready var laser_dust: GPUParticles3D = %LaserDust
|
@onready var laser_dust: GPUParticles3D = %LaserDust
|
||||||
@ -21,9 +21,12 @@ func _process(_delta: float) -> void:
|
|||||||
if c is Node3D:
|
if c is Node3D:
|
||||||
(c as Node3D).global_position = child_pos
|
(c as Node3D).global_position = child_pos
|
||||||
|
|
||||||
var new_gunk_rid: RID = get_collider_rid()
|
var new_gunk_id: int = 0
|
||||||
if new_gunk_rid != gunk_rid:
|
var collider: Object = get_collider()
|
||||||
gunk_rid = new_gunk_rid
|
if collider:
|
||||||
|
new_gunk_id = collider.get_instance_id()
|
||||||
|
if new_gunk_id != gunk_id:
|
||||||
|
gunk_id = new_gunk_id
|
||||||
if gunkable:
|
if gunkable:
|
||||||
# Disconnect old signals to avoid emitting from previous node and accumulating connections
|
# 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):
|
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(
|
gunkable.clear_total_updated.disconnect(
|
||||||
gunk_dust._on_gunkable_clear_total_updated
|
gunk_dust._on_gunkable_clear_total_updated
|
||||||
)
|
)
|
||||||
gunkable = Gunkable.get_component(get_collider())
|
gunkable = Gunkable.get_component(collider)
|
||||||
if gunkable:
|
if gunkable:
|
||||||
# Connect signals of new gunkable to our gunk dust
|
# Connect signals of new gunkable to our gunk dust
|
||||||
if !gunkable.painted_at_point.is_connected(gunk_dust._on_gunkable_painted_at_point):
|
if !gunkable.painted_at_point.is_connected(gunk_dust._on_gunkable_painted_at_point):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user