xrjamfeb2025/scenes/base_game_scene.gd
2025-02-14 17:17:23 -07:00

32 lines
934 B
GDScript

extends XRToolsSceneBase
func scene_loaded(user_data = null):
super.scene_loaded(user_data)
_reset_manipulators()
func _ready():
# for editor testing when scene is directly loaded
_reset_manipulators()
func _reset_manipulators():
# reset the manipulators (the loaded scene has them in the final position)
# Get all manipulators in the scene
var manipulators = get_tree().get_nodes_in_group("manipulators")
# Calculate spacing between manipulators
var total_width = manipulators.size() - 1
var start_x = -total_width / 2.0
# Position each manipulator in a line
for i in range(manipulators.size()):
var manipulator = manipulators[i]
var x_pos = start_x + i
manipulator.transform.origin = Vector3(x_pos, 1.0, -1.0)
manipulator.transform.basis = Basis.IDENTITY
# Reset the attractor sphere radius
var attractor = manipulator.get_node("VisualAttractorSphere")
if attractor:
attractor.radius = 0.5