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

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Warning to CR developers about .IsFacing

kaihaider

Community Developer
Joined
May 18, 2010
Messages
1,325
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