- Home /
Vector3.Angle, set range on individual axis
Hi,
I've followed the example on Unity's documentation about Vector3.Angle to see if a target is inside a certain specified angle from the player. So far so good, but I've would somehow like to set the size of the angles differently for the x and y axis, so the player e.g. detects broader in the x-axis, and narrower in the y-axis. Not really sure how to attack it. Here's the code as is now:
Vector3 enemyDir = enemy.transform.position - transform.position;
Vector3 frw = transform.forward;
float angle = Vector3.Angle(enemyDir, frw);
if(angle < 10.0f)
{
print ("In range");
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613165613im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to find direction Vector for a collision surface? 1 Answer
Banking an object in relation to its turn 1 Answer
Interpolate a rotation with angle axis 1 Answer
Get input's Joypad. 0 Answers