示例#1
0
    public override void _Ready()
    {
        shadowRoot = GetParent <Node25D>();
        int index = shadowRoot.GetPositionInParent();

        targetMath = shadowRoot.GetParent().GetChild <Node25D>(index - 1).GetChild <Spatial>(0);
    }
示例#2
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;
        }
    }
示例#3
0
 public override void _Ready()
 {
     _parent = GetParent <Node25D>();
 }
 public override void _Ready()
 {
     _parent     = GetParent <Node25D>();
     _parentMath = _parent.GetChild <PlayerMath25D>(0);
 }