Godot Version
4.4.1
Question
Hello, I have an object pool of decals that I am am hoping to reparent to other objects so they can move with dynamic objects like rigid body crates and stuff. I’ve noticed when reparenting the decal for the first time, it works fine, but when the same decal is “spawned” the second time, it seems to keep the last parents scale.
var object_succesfully_spawned: bool = false
for i in range(allocated_objects):
if object_index >= allocated_objects:
object_index = 0
if "available" in object_array[object_index] and object_array[object_index].available:
object_array[object_index].global_position = spawn_location
if spawn_rotation: rotate_object(object_array[object_index], spawn_rotation)
if object_array[object_index].has_signal("object_hidden"):
object_array[object_index].object_hidden.connect(func(): unparent(object_array[object_index]),CONNECT_ONE_SHOT)
if object_array[object_index].has_method("spawn_object"):
object_array[object_index].spawn_object()
if parent : object_array[object_index].reparent(parent)
print(object_array[object_index].scale)
object_succesfully_spawned = true
return object_array[object_index]
else:
push_error("Object doesn't have spawn method.")
return null
object_index += 1
break
object_index += 1
if !object_succesfully_spawned:
printerr("object not available, try allocating more objects to this spawner.", self)
pass
return null
I’ve also tried writing a function that changes all the nodes properties back to it’s default values by a signal that is emitted by the object when it is done hiding, but I’m still getting the same results.
func unparent(object : Node3D)->void:
print("unparented")
object.reparent(Engine.get_main_loop().current_scene)
object.position = Vector3.ZERO
object.rotation = Vector3.ZERO
object.global_position = Vector3.ZERO
object.global_rotation = Vector3.ZERO
object.scale = Vector3.ONE
object.global_scale(Vector3.ONE)
here’s the link to what it looks like: