// Initializes after _ready due to the onready vars, called manually in Viewport25D.gd. // Sets up the points based on the basis values of the Node25D. public void Initialize() { var basis = node25d.Basis25D; for (int i = 0; i < 3; i++) { lines[i].Points[1] = basis[i] * 3; } GlobalPosition = node25d.GlobalPosition; spatialNode = node25d.GetChild <Spatial>(0); }
public override void _Process(float delta) { if (Input.IsActionPressed("exit")) { GetTree().Quit(); } if (Input.IsActionJustPressed("view_cube_demo")) { GetTree().ChangeScene("res://assets/demo_scene.tscn"); return; } if (_isParentReady) { RotateX(delta * (Input.GetActionStrength("move_back") - Input.GetActionStrength("move_forward"))); RotateY(delta * (Input.GetActionStrength("move_right") - Input.GetActionStrength("move_left"))); RotateZ(delta * (Input.GetActionStrength("move_counterclockwise") - Input.GetActionStrength("move_clockwise"))); if (Input.IsActionJustPressed("reset_position")) { Transform = Transform.Identity; } for (int i = 0; i < 27; i++) { _cubePointsMath[i].GlobalTransform = _cubeMathSpatials[i].GlobalTransform; } } else { // This code block will be run only once. It's not in _Ready() because the parent isn't set up there. for (int i = 0; i < 27; i++) { PackedScene myCubePointScene = cubePointScene.Duplicate(true) as PackedScene; Node25D cubePoint = myCubePointScene.Instance() as Node25D; cubePoint.Name = "CubePoint #" + i; _cubePointsMath[i] = cubePoint.GetChild <Spatial>(0); _parent.AddChild(cubePoint); } _isParentReady = true; } }
public override void _Ready() { _parent = GetParent <Node25D>(); _parentMath = _parent.GetChild <PlayerMath25D>(0); }