What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Warning to CR developers about .IsFacing

kaihaider

Community Developer
Joined
May 18, 2010
Messages
1,325
Reaction score
5
The gameobject method .IsFacing only returns true if you are looking directly at it.

So unless you're aiming a sniper rifle, you'll probably want to use something like this:
Code:
        public static bool IsFacing(GameObject o)        {
            float headingTowardsTarget= MathEx.NormalizeRadian(MathHelper.CalculateHeading(Core.Me.Location, o.Location) + (float)Math.PI);
            float d = Math.Abs(MathEx.NormalizeRadian(Core.Me.Heading - headingTowardsTarget));
            if (d > Math.PI) d = Math.Abs(d - 2 * (float)Math.PI);
            //Logging.Write("Differance: " + d);
            return d < 0.785f;
        }
 
Last edited:
Back
Top