1
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user