コード例 #1
0
    private Vector3 GetLowerWheelPosition(MowerController controller)
    {
        Vector3 rightWheelPosition = controller.mRightWheelPosition.position;
        Vector3 leftWheelPosition  = controller.mLeftWheelPosition.position;

        if (rightWheelPosition.y > leftWheelPosition.y)
        {
            return(leftWheelPosition);
        }
        else if (leftWheelPosition.y > rightWheelPosition.y)
        {
            return(rightWheelPosition);
        }
        else
        {
            if (mApplyForceRight)
            {
                return(rightWheelPosition);
            }
            else
            {
                return(leftWheelPosition);
            }
        }
    }
コード例 #2
0
    private void ApplyForceAtCasterPosition(Collider other, Vector3 forceDirection)
    {
        //Debug.Log(forceDirection + " : froceDirection");
        //Debug.Log(other.transform.right + " :mowerRight");

        MowerController controller     = other.transform.parent.GetComponent <MowerController>();
        Rigidbody       mowerRigidBody = other.transform.parent.GetComponent <Rigidbody>();

        Vector3 mowerCastersPosition = controller.mCasterTransform.position;
        Vector3 lowerWheelLocation   = GetLowerWheelPosition(controller);

        //Debug.Log(mowerRigidBody.velocity.magnitude);
        IMUDirectionArrow imuArrowScript = controller.GetComponent <IMUDirectionArrow>();

        if (imuArrowScript == null)
        {
            mowerRigidBody.AddForceAtPosition(forceDirection * (mDownwardForceMagnitude), mowerCastersPosition);
        }
        else if (!controller.GetComponent <IMUDirectionArrow>().isActiveAndEnabled)
        {
            mowerRigidBody.AddForceAtPosition(forceDirection * (mDownwardForceMagnitude), mowerCastersPosition);
        }

        ApplyScaledTorque(forceDirection, other, mowerCastersPosition, lowerWheelLocation);

        //

        //ApplyTorqueAtPositionAroundPosition(mForceMagnitude * forceDirection, mowerCastersPosition, lowerWheelLocation, mowerRigidBody);
    }
コード例 #3
0
    // On No button click, set answer as No and MoveMower..
    public void OnNoButtonClick()
    {
        buttonClick = GameObject.Find("ButtonClickSound").GetComponent <AudioSource>();
        buttonClick.Play();
        Debug.Log("NO Button Click");
        Prologue.GetInstance().GetAnswer("<No>");
        MowerController mowerController = GameObject.Find("LawnMower").GetComponent <MowerController>();

        mowerController.MoveMower();
    }