Ejemplo n.º 1
0
 private void Awake()
 {
     playerMoveScript    = GetComponent <PlayerLeftRightMove>();
     playerJumpScript    = GetComponent <PlayerJump>();
     playerJetJumpScript = GetComponent <PlayerJetJump>();
     playerFlyScript     = GetComponent <PlayerFly>();
 }
Ejemplo n.º 2
0
 // Sets up initial movement mode
 private void SetUpMovements()
 {
     playerJump         = GetComponent <PlayerJump>();
     playerFly          = GetComponent <PlayerFly>();
     playerJump.enabled = true;
     playerFly.enabled  = false;
 }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        playerJumpScript    = GetComponent <PlayerJump>();
        playerJetJumpScript = GetComponent <PlayerJetJump>();
        playerFlyScript     = GetComponent <PlayerFly>();
        playerRigidbody2D   = GetComponent <Rigidbody2D>();

        ToggleJumpModes();
    }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     _playerFly = PlayerFly.instance;
 }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        //updates variables
        float mouseX = Input.GetAxis("Mouse X");
        float mouseY = -Input.GetAxis("Mouse Y");

        //calculate our post-mouse movement
        rotY += mouseX * mouseSensitivity * Time.deltaTime;
        rotX += mouseY * mouseSensitivity * Time.deltaTime;

        //clamp the rot to a narrow cone

        //clamp the local rotation
        rotX = Mathf.Clamp(rotX, -30, 30);
        rotY = Mathf.Clamp(rotY, -30, 30);

        const float kRotVal = 0.5F;

        //do a little bit of rotation
        turnTimer += Time.deltaTime;
        if ((Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S)) && turnTimer >= .05)
        {
            turnSpeed += .1f;
            turnTimer  = 0;
        }

        if ((!Input.GetKey(KeyCode.A) || !Input.GetKey(KeyCode.S)) && turnTimer >= .05)
        {
            turnSpeed = 0;
        }

        turnSpeed = Mathf.Clamp(turnSpeed, 1, 2);

        PlayerFly pf = Airplane.GetComponent <PlayerFly>();

        if (pf != null && pf.impulse > 0)
        {
            if (rotY > kRotVal)
            {
                //rotY -= kRotVal;
                Airplane.transform.RotateAround(Airplane.transform.up, +kRotVal * (Mathf.PI / 180.0F) * turnSpeed * 1000);
            }
            if (rotY < -kRotVal)
            {
                //rotY += kRotVal;
                Airplane.transform.RotateAround(Airplane.transform.up, -kRotVal * (Mathf.PI / 180.0F) * turnSpeed * 1000);
            }


            if (rotX > kRotVal)
            {
                //rotX -= kRotVal;
                Airplane.transform.RotateAround(Airplane.transform.right, +kRotVal * (Mathf.PI / 180.0F) * 1000);
            }
            if (rotX < -kRotVal)
            {
                //rotX += kRotVal;
                Airplane.transform.RotateAround(Airplane.transform.right, -kRotVal * (Mathf.PI / 180.0F) * 1000);
            }
        }

        Vector3 euler = Airplane.transform.localRotation.eulerAngles;

        euler.z = 0;
        //always maintain that the airplane's roll is zero
        Airplane.transform.localRotation = Quaternion.Euler(euler);

        Quaternion localRotation = Quaternion.Euler(rotX, rotY, 0.0f);

        transform.localRotation = localRotation;
    }