コード例 #1
0
    public override Vector3 CalculateForce( )
    {
        if (manager.timePassedAvoid > timeMax)
        {
            manager.timePassedAvoid = 0.0f;

            pointOnSphere = Vector3.zero;

            if (left)
            {
                pointOnSphere.x = Random.Range(-0.8f, -0.6f);
                left            = false;
            }
            else
            {
                pointOnSphere.x = Random.Range(0.8f, 0.6f);
                left            = true;
            }

            pointOnSphere.Normalize();
            pointOnSphere *= radius;
        }

        sphere.transform.position = manager.transform.position + (Vector3.forward * dist);
        sphere.transform.forward  = Vector3.forward;

        Vector3 targetPos = sphere.transform.TransformPoint(pointOnSphere);

        Debug.DrawLine(manager.transform.position, targetPos, Color.red);
        Debug.DrawLine(manager.transform.position, sphere.transform.position, Color.green);
        Debug.DrawLine(sphere.transform.position, sphere.transform.position + (sphere.transform.forward * 10), Color.blue);

        return(seek.Calc(targetPos));
    }
コード例 #2
0
    public override Vector3 CalculateForce( )
    {
        Vector3 targetPos = manager.transform.position + (manager.transform.forward * manager.maxSpeed);

        Vector3 result = seek.Calc(targetPos);

        return(result);
    }
コード例 #3
0
    public override Vector3 CalculateForce()
    {
        pointOnSphere   = Vector3.zero;
        pointOnSphere.y = 1.0f;
        pointOnSphere  *= radius;

        sphere.transform.position = manager.transform.position + (Vector3.forward * dist);
        sphere.transform.forward  = Vector3.forward;

        Vector3 targetPos = sphere.transform.TransformPoint(pointOnSphere);

        Debug.DrawLine(manager.transform.position, targetPos, Color.yellow);
        Debug.DrawLine(manager.transform.position, sphere.transform.position, Color.yellow);
        Debug.DrawLine(sphere.transform.position, sphere.transform.position + (sphere.transform.forward * 10), Color.yellow);

        return(seek.Calc(targetPos));
    }
コード例 #4
0
    public override Vector3 CalculateForce( )
    {
        Vector3 target = manager.leader.transform.position;

        return(seek.Calc(target));
    }