This commit is contained in:
CortexCore
2023-11-15 23:55:06 +08:00
parent 5446067f91
commit 70247f0242
82 changed files with 3271 additions and 579 deletions

View File

@@ -39,6 +39,24 @@ namespace BITKit
}
public static partial class MathV
{
public static bool InFovRange(Vector3 selfPosition,Vector3 selfForward, Vector3 target, float fov)
{
var direction = target - selfPosition;
var angle = Vector3.Angle(direction, selfForward);
return angle < fov;
}
public static bool IsForward(Vector3 selfPosition, Vector3 selfForward,Vector3 targetPos)
{
// Get the direction from referencePos to targetPos
Vector3 directionToTarget = (targetPos - selfPosition).normalized;
// Calculate the dot product
float dotProduct = Vector3.Dot(directionToTarget, selfForward);
// If dot product is greater than 0, targetPos is in front of referencePos
return dotProduct > 0;
}
// 对于 Vector3
public static Vector3 AlignRotation(Vector3 eulerAngles, float angleIncrement)
{