Skip to content

Commit

Permalink
Merge pull request #187 from inworld-ai/mwPlaygroundPort
Browse files Browse the repository at this point in the history
Fixed spelling mistake and updated Sight Angle to allow for full 360 degrees of view
  • Loading branch information
mattkwilson authored Mar 26, 2024
2 parents 56f9d11 + a4ef213 commit 3092b8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
21 changes: 14 additions & 7 deletions Assets/Inworld/Inworld.Assets/Scripts/SightAngle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ public class SightAngle : MonoBehaviour
[SerializeField] float m_SightAngle = 90f;
[Range(1, 30)]
[SerializeField] float m_SightDistance = 10f;
[Range(0, 100)]
[Tooltip("How much of an impact distance will make in the Priority calculation.")]
[SerializeField] float m_DistancePriorityFactor = 10;
[Range(0, 10)]
[Tooltip("How much of an impact the Player's forward direction will have in the Priority calculation.")]
[SerializeField] float m_PlayerAngleWeight = 1;
[Range(0, 10)]
[Tooltip("How much of an impact distance will have in the Priority calculation.")]
[SerializeField] float m_DistanceWeight = 0.5f;
[Range(0, 10)]
[Tooltip("How much of an impact the character's forward direction will have in the Priority calculation.")]
[SerializeField] float m_CharacterAngleWeight = 0.15f;
[Range(0.1f, 1f)]
[SerializeField] float m_RefreshRate = 0.25f;

Expand Down Expand Up @@ -74,14 +80,15 @@ void CheckPriority()
{
Vector3 vecDirection = (m_CameraTransform.position - m_HeadTransform.position).normalized;
float fAngle = Vector3.Angle(vecDirection, transform.forward);
if (fAngle > m_SightAngle * 0.5f)
if (fAngle > m_SightAngle)
{
Character.Priority = -1f;
}
else
{
Vector3 vecPlayerDirection = -vecDirection;
Character.Priority = Vector3.Angle(vecPlayerDirection, m_CameraTransform.forward) + distance * m_DistancePriorityFactor;
Character.Priority = (Vector3.Angle(-vecDirection, m_CameraTransform.forward) / 180f) * m_PlayerAngleWeight;
Character.Priority += (distance / m_SightDistance) * m_DistanceWeight;
Character.Priority += (Vector3.Angle(m_HeadTransform.forward, vecDirection) / m_SightAngle) * m_CharacterAngleWeight;
}
}
}
Expand All @@ -92,7 +99,7 @@ void OnDrawGizmosSelected()

Gizmos.color = Color.cyan;
Vector3 trPosition = m_HeadTransform.position;
for (float angle = m_SightAngle * -0.5f; angle < m_SightAngle * 0.5f; angle += m_SightAngle * 0.05f)
for (float angle = -m_SightAngle; angle < m_SightAngle; angle += m_SightAngle * 0.05f)
{
Gizmos.DrawLine(trPosition, trPosition + Quaternion.AngleAxis(angle, transform.up) * transform.forward * m_SightDistance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Serialization;

namespace Inworld.Sample.Innequin
{
Expand All @@ -17,7 +18,7 @@ public class FaceTransform
public string name;
public int animIndex;
public float imgHeight;
public Texture eyeBlow;
[FormerlySerializedAs("eyeBlow")] public Texture eyeBrow;
public Texture eye;
public Texture eyeClosed;
public Texture nose;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void _MorphFaceEmotion(FacialEmotion emotion)
FaceTransform facialData = m_FaceTransformData[emotion.ToString()];
if (facialData == null)
return;
m_matEyeBlow.mainTexture = facialData.eyeBlow;
m_matEyeBlow.mainTexture = facialData.eyeBrow;
m_CurrentEyeOpen = facialData.eye;
m_CurrentEyeClosed = facialData.eyeClosed;
m_matNose.mainTexture = facialData.nose;
Expand Down

0 comments on commit 3092b8b

Please sign in to comment.