Exemplo n.º 1
0
    void FollowObject(IDetectableObject Object)
    {
        Vector3    DirToObject     = (Object.GetPosition() - Head.transform.position).normalized;
        Quaternion DirToObjectQuat = Quaternion.LookRotation(DirToObject);

        // lerp rotation
        Quaternion HeadRotation   = Head.transform.rotation;
        Quaternion LerpedRotation = Quaternion.Slerp(HeadRotation, DirToObjectQuat, 0.5f);

        Head.transform.rotation = LerpedRotation;
        //Debug.Log ("Rotation" + DirToObjectQuat);
    }
Exemplo n.º 2
0
    // TODO: Calculate detection for every gameobject, then train attention to most detected
    float CalculateDetection(IDetectableObject DetectableObject)
    {
        float DetectionSensitivity = 0f;

        // #Distance from agent#
        Vector3 ToObjectVector = DetectableObject.GetPosition() - transform.position;
        Vector3 DirToObject    = ToObjectVector.normalized;

        if (ToObjectVector.magnitude > 1)
        {
            DetectionSensitivity += (1 / ToObjectVector.magnitude) * Static_Scalar_Distance;
        }
        else
        {
            DetectionSensitivity += Static_Scalar_Distance;
        }


        if (DetectableObject.UsesFacing())
        {
            // #Sensing onlooker#
            float SenseOnlookerDot = Vector3.Dot(DirToObject, DetectableObject.GetFacingDirection());
            // Multiply by -1 here cause we want the sensitivity of them facing away from each other
            //DetectionSensitivity += SenseOnlookerDot * -1 * Scalar_Onlooker;

            // #Eye contact#
            float EyeContactDot = Vector3.Dot(Head.transform.forward, DetectableObject.GetFacingDirection());
            // again by -1
            //DetectionSensitivity += EyeContactDot * -1 * Scalar_EyeContact;
        }

        // #Within FOV of agent#
        float FOVDot = Vector3.Dot(Head.transform.forward, DirToObject);

        //DetectionSensitivity += FOVDot * Scalar_FOV;

        //TODO: Sound, alertness of other agents to object

        Debug.Log("D: " + DetectionSensitivity);
        return(DetectionSensitivity);
    }