예제 #1
0
    public float leftStickXValue = 0.1f;         //The value of the left stick X at which the dragon will 'bank'.



    // Use this for initialization
    void Start()
    {
        flyController     = GetComponent <DragonControllerFly>();
        groundController  = GetComponent <DragonControllerGround>();
        idleFlyController = GetComponent <DragonControllerIdleFly>();
        stats             = GetComponent <DragonStats>();
        rb       = GetComponent <Rigidbody>();
        animator = GetComponent <Animator>();

        flyController.enabled     = false;
        idleFlyController.enabled = true;
        groundController.enabled  = false;

        //if (InputManager.Devices.Count <= playerIndex)
        //{
        //    return;
        //}
        device = InputManager.Devices[playerIndex];
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (groundController == null)
        {
            groundController = GetComponent <DragonControllerGround>();
        }

        /* if (playerIndex == 1)
         * {
         *   return;
         * }*/
        if (isGrounded == true)
        {
            animator.SetBool("IsGrounded", true);
            idleFlyController.enabled = false;
            groundController.enabled  = true;

            rb.useGravity = true;
        }
        else
        {
            animator.SetBool("IsGrounded", false);
            //StaminaUpdate();
            groundController.enabled = false;

            rb.useGravity = false;
        }

        if (idleFlyController.moveSpeed >= idleFlySpeedLimit)
        {
            if (idleFlyController.enabled == true)
            {
                idleFlyController.enabled = false;
                animator.SetBool("SetFlying", true);
                flyController.enabled   = true;
                flyController.moveSpeed = flyStartSpeed;
            }
        }
        if (flyController.moveSpeed <= flySpeedLimit)
        {
            if (flyController.enabled == true)
            {
                flyController.enabled = false;
                animator.SetBool("SetFlying", false);
                idleFlyController.enabled   = true;
                idleFlyController.moveSpeed = idleFlyStartSpeed;
            }
        }

        if (rb.drag >= 10)
        {
            rb.drag = 10;
        }
        else if (rb.drag <= 2)
        {
            rb.drag = 2;
        }

        //Lock the velocity in the X and Z Vector to cap speed
        if (velocity.x > XVelocityCap)
        {
            velocity.x = XVelocitySet;
        }
        else if (velocity.x < -XVelocityCap)
        {
            velocity.x = -XVelocitySet;
        }
        if (velocity.z > ZVelocityCap)
        {
            velocity.z = ZVelocitySet;
        }
        else if (velocity.z < -ZVelocityCap)
        {
            velocity.z = -ZVelocitySet;
        }
    }