- Home /
Check if object is facing a point (ignore y axis)
I found a pretty good code here to check if my object is facing another, only issue is, when my object is above the point it doesn't know. I want it to return true if the object is simply looking at the point's direction despite being above it
This is what it looks like right now: if(Vector3.Angle(transform.forward, target - transform.position) < 10f){}
And what would you consider to be "looking at the point's direction"?
Answer by Hellium · Mar 20, 2018 at 02:16 PM
Vector3 direction = target - transform.position ;
direction.y = 0 ;
if(Vector3.Angle(transform.forward, direction ) < 10f)
{
// Do something
}
Your answer

Follow this Question
Related Questions
Why The player don't move? 0 Answers
BCE0019: 'text' is not a member of UnityEngine.component 2 Answers
I need a script to jump and double jump 2 Answers
How to make a 3D character move? 4 Answers
Simple - Visual Studio Code not loading script when icon is clicked through unity *Video provided* 0 Answers