Exemplo n.º 1
0
    void FixedUpdate()
    {
        if (enemy.stunTill > Time.time)
        {
            GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            return;
        }

        float characterOrientation = transform.rotation.eulerAngles.z * Mathf.Deg2Rad;

        /* Update the wander orientation */
        updateWanderOrientation(characterOrientation);

        /* Calculate the combined target orientation */
        float targetOrientation = wanderOrientation + characterOrientation;

        /* Calculate the center of the wander circle */
        Vector3 targetPosition = transform.position + (orientationToVector(characterOrientation) * wanderOffset);

        //		debugRing.transform.position = targetPosition;

        /* Calculate the target position */
        targetPosition = targetPosition + (orientationToVector(targetOrientation) * wanderRadius);

        //		Debug.DrawLine (transform.position, targetPosition);


        Vector2 acceleration = steeringUtils.seek(targetPosition);

        steeringUtils.steer(acceleration);

        steeringUtils.lookWhereYoureGoing();
    }
Exemplo n.º 2
0
    void FixedUpdate()
    {
        float characterOrientation = transform.rotation.eulerAngles.z * Mathf.Deg2Rad;

        /* Update the wander orientation */
        wanderOrientation += randomBinomial() * wanderRate;

        /* Calculate the combined target orientation */
        float targetOrientation = wanderOrientation + characterOrientation;

        /* Calculate the center of the wander circle */
        Vector3 targetPosition = transform.position + (orientationToVector(characterOrientation) * wanderOffset);

        //debugRing.transform.position = targetPosition;

        /* Calculate the target position */
        targetPosition = targetPosition + (orientationToVector(targetOrientation) * wanderRadius);

        //Debug.DrawLine (transform.position, targetPosition);


        Vector2 acceleration = steeringUtils.seek(targetPosition);

        steeringUtils.steer(acceleration);

        steeringUtils.lookWhereYoureGoing();
    }