Exemple #1
0
        // Handles Moving Functionality
        void Movement()
        {
            float inputV = Input.GetAxis("Vertical");
            float inputH = Input.GetAxis("Horizontal");

            // Check if up arrow is pressed
            if (inputV > 0)
            {
                // Accelerate player
                movement.Accelerate(transform.up);
            }
            // Check if horizontal axis (left or right arrow) is pressed
            // Rotate in correct direction
            movement.Rotate(inputH);

            // If right arrow is pressed
            if (Input.GetKey(KeyCode.RightArrow))
            {
                movement.RotateRight();
            }
            // Rotate right

            // If left arrow is pressed
            if (Input.GetKey(KeyCode.LeftArrow))
            {
                movement.RotateLeft();
            }
            //Rotate left
            #endregion
        }
        // Update is called once per frame
        void Update()
        {
            float inputV = Input.GetAxis("Vertical");
            float inputH = Input.GetAxis("Horizontal");

            if (inputV > 0)
            {
                movement.Accelerate(transform.up);
            }
            movement.Rotate(inputH);
        }
Exemple #3
0
        // Handles Moving Functionality
        void Movement()
        {
            float inputV = Input.GetAxis("Vertical");
            float inputH = Input.GetAxis("Horizontal");

            // Check if up arrow is pressed
            if (inputV > 0)
            {
                // Accelerate player
                movement.Accelerate(transform.up);
            }
            // Rotate depending on what inputH direction is
            movement.Rotate(inputH);
        }