By continuing to use this site, you agree to allow us to store cookies on your computer. :)

## Recommended Posts

Hello,

i am trying to figure out how to get a facing target from the vector3, the angle, and targets vector3.

We have the following data:
- Our Vector3 Position (X, Y, Z) (100, 100, 0)
- Our Current Facing Angle (Pitch, Yaw) (90, 180)
- Targets Vector3 Position (X, Y, Z) (200, 200, 0)

How do we calculate the Angle (Pitch, Yaw) that I would need to reach to be facing our target.

I just need the math function to take the input and output the info i need. the rest i can do.

-Smokie

##### Share on other sites

I believe this should work:

```        /// <summary>
/// Used to get the facing from two positions based on the origin rotation.
/// </summary>
/// <param name="from">The 1. position.</param>
/// <param name="to">The 2. position.</param>
/// <param name="originRotation">The origin rotation.</param>
/// <returns>Negative radian on the right; positive on the left.</returns>
public float FacingCenter(WoWPoint from, WoWPoint to, float originRotation)
{
var face = NormalizeRadian(Atan2Rotation(from, to) - originRotation);
if (face < Math.PI)
return -face;
}

/// <summary>
/// Used to normalize the input radian.
/// </summary>
{
return (float) (-(- radian % (2.0 * Math.PI)) + 2.0 * Math.PI);
}

/// <summary>
/// Used to calculate atan2 of to positions.
/// </summary>
/// <param name="from">Position 1.</param>
/// <param name="to">Position 2.</param>
/// <returns></returns>
{
}

/// <summary>
/// Used to calculate new position by parameter.
/// </summary>
/// <param name="from">The position to calculate from.</param>
/// <param name="rotation">The rotation of the object in radians.</param>
/// <returns></returns>
public static WoWPoint CalculateNewPosition(WoWPoint from, float rotation, float radius)
{
return new WoWPoint(Math.Sin(rotation) * radius + from.X, Math.Cos(rotation) * radius + from.Y, from.Z);
}```

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account. ×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.