Esempio n. 1
0
 // Update is called once per frame
 protected override void Update()
 {
     controlledSteeringUpdate = new SteeringOutput();
     //controlledSteeringUpdate.angular = myRotateType.getSteering().angular;
     controlledSteeringUpdate.linear = myMoveType.getSteering().linear;
     base.Update();
 }
Esempio n. 2
0
    // Update is called once per frame
    protected virtual void Update()
    {
        //Update pos rot
        transform.position += linearVelocity * Time.deltaTime;
        Vector3 angularIncrement = new Vector3(0, angularVelocity * Time.deltaTime, 0);

        if (float.IsNaN(angularIncrement.y))
        {
        }
        else
        {
            transform.eulerAngles += angularIncrement;
        }
        //Debug.Log(angularIncrement);

        SteeringOutput steering = new SteeringOutput();

        //Get Steerings
        if (bIsSeeking)
        {
            steering = mySeek.getSteering();
        }
        else
        {
            //steering = myFlee.getSteering();
        }
        if (bCanArrive)
        {
            SteeringOutput _arrvSteering = myArrv.getSteering();
            if (_arrvSteering != null)
            {
                linearVelocity  += _arrvSteering.linear * Time.deltaTime;
                angularVelocity += _arrvSteering.angular * Time.deltaTime;
            }
            else
            {
                linearVelocity = Vector3.zero;
            }
        }
        if (bDoesAlign)
        {
            SteeringOutput _algnSteering = myAlgn.getSteering();
            if (_algnSteering != null)
            {
                steering.angular += _algnSteering.angular * Time.deltaTime;
            }
            else
            {
                angularVelocity = 0f;
            }
        }

        if (bDoesFace)
        {
            SteeringOutput _faceSteering = myFace.getSteering();
            if (_faceSteering != null)
            {
                angularVelocity += _faceSteering.angular * Time.deltaTime;
            }
        }
        if (bDoesLookWhereGoing)
        {
            SteeringOutput _lwygSteering = myLWYG.getSteering();
            if (_lwygSteering != null)
            {
                angularVelocity += _lwygSteering.angular * Time.deltaTime;
            }
        }
        if (bDoesFollowPath)
        {
            SteeringOutput _fpthSteering = myFPth.getSteering();
            if (_fpthSteering != null)
            {
                linearVelocity += _fpthSteering.linear * Time.deltaTime;
            }
        }
        if (bDoesSeparate)
        {
            SteeringOutput _seprSteering = mySepr.getSteering();
            if (_seprSteering != null)
            {
                linearVelocity += _seprSteering.linear * Time.deltaTime;
            }
        }
        if (bDoesPursue)
        {
            SteeringOutput _prsuSteering = myPrsu.getSteering();
            if (_prsuSteering != null)
            {
                linearVelocity += _prsuSteering.linear * Time.deltaTime;
            }
        }
        if (bDoesAvoidColl)
        {
            SteeringOutput _clAvSteering = myClAv.getSteering();
            if (_clAvSteering != null)
            {
                linearVelocity += _clAvSteering.linear * Time.deltaTime;
            }
        }
        if (bDoesObstAvoid)
        {
            SteeringOutput _obAvSteering = myObAv.getSteering();
            if (_obAvSteering != null)
            {
                linearVelocity += _obAvSteering.linear * Time.deltaTime;
            }
        }



        ///Check for controlled steering updates
        if (controlledSteeringUpdate != null)
        {
            linearVelocity  += controlledSteeringUpdate.linear * Time.deltaTime;
            angularVelocity += controlledSteeringUpdate.angular * Time.deltaTime;
        }


        //update lin ang vel

        linearVelocity  += steering.linear * Time.deltaTime;
        angularVelocity += steering.angular * Time.deltaTime;
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        //Update pos rot
        transform.position += linearVelocity * Time.deltaTime;
        Vector3 angularIncrement = new Vector3(0, angularVelocity * Time.deltaTime, 0);

        if (float.IsNaN(angularIncrement.y))
        {
        }
        else
        {
            transform.eulerAngles += angularIncrement;
        }
        //Debug.Log(angularIncrement);

        SteeringOutput steering = new SteeringOutput();

        //Get Steerings
        if (bIsSeeking)
        {
            steering = mySeek.getSteering();
        }
        else
        {
            //steering = myFlee.getSteering();
        }
        if (bCanArrive)
        {
            SteeringOutput _arrvSteering = myArrv.getSteering();
            if (_arrvSteering != null)
            {
                linearVelocity  += _arrvSteering.linear * Time.deltaTime;
                angularVelocity += _arrvSteering.angular * Time.deltaTime;
            }
            else
            {
                linearVelocity = Vector3.zero;
            }
        }
        if (bDoesAlign)
        {
            SteeringOutput _algnSteering = myAlgn.getSteering();
            if (_algnSteering != null)
            {
                steering.angular += _algnSteering.angular * Time.deltaTime;
            }
            else
            {
                angularVelocity = 0f;
            }
        }

        if (bDoesFace)
        {
            SteeringOutput _faceSteering = myFace.getSteering();
            if (_faceSteering != null)
            {
                angularVelocity += _faceSteering.angular * Time.deltaTime;
            }
        }
        if (bDoesLookWhereGoing)
        {
            SteeringOutput _lwygSteering = myLWYG.getSteering();
            if (_lwygSteering != null)
            {
                angularVelocity += _lwygSteering.angular * Time.deltaTime;
            }
        }
        if (bDoesFollowPath)
        {
            SteeringOutput _fpthSteering = myFPth.getSteering();
            if (_fpthSteering != null)
            {
                linearVelocity += _fpthSteering.linear * Time.deltaTime;
            }
        }

        //update lin ang vel

        linearVelocity  += steering.linear * Time.deltaTime;
        angularVelocity += steering.angular * Time.deltaTime;
    }