コード例 #1
0
    private void RotateTurret(float rot)
    {
        /*
         * To do turret rotation vertically, we will likely need to use quaternion here
         *
         * For some reason, when we rotate by two directions, the turret moves all over the place (around the tank)
         */

        //GD.Print(yaw);
        turret.RotateY(rot);
        //turret.RotateX(pitch);
        //turret.SetRotation(new Vector3(pitch, yaw, 0));
    }
コード例 #2
0
    private void PlaceExitWall(RoomDirection location)
    {
        //Swing the directions back should become forward and so on
        if (exitPlaced)
        {
            return;
        }
        switch (location)
        {
        case RoomDirection.BACK:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, backWall.Transform.origin);
            exitWall.RotateY(Mathf.Deg2Rad(90));
            AddChild(exitWall);
            backWall.QueueFree();
            //Instance the exit wall her and position it to align
            break;

        case RoomDirection.FRONT:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, frontWall.Transform.origin);
            exitWall.RotateY(Mathf.Deg2Rad(-90));
            AddChild(exitWall);
            frontWall.QueueFree();
            break;

        case RoomDirection.LEFT:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, leftWall.Transform.origin);
            AddChild(exitWall);
            leftWall.QueueFree();
            break;

        case RoomDirection.RIGHT:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, rightWall.Transform.origin);
            AddChild(exitWall);
            rightWall.QueueFree();
            break;

        case RoomDirection.TOP:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, roofWall.Transform.origin);
            exitWall.RotateX(Mathf.Deg2Rad(90));
            AddChild(exitWall);
            roofWall.QueueFree();
            break;

        case RoomDirection.BOTTOM:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, floorWall.Transform.origin);
            exitWall.RotateX(Mathf.Deg2Rad(-90));
            AddChild(exitWall);
            floorWall.QueueFree();
            break;
        }
    }