AngleToVector(float)

Converts an angle into a vector.

vector AngleToVector(
    float fAngle
);

Parameters

fAngle

The degrees of an angle to convert into a vector.


Description

Returns the value of fAngle converted into a vector.



Version

1.30

Example

// stalker script (but in an NPC's OnHeartbeat script)
// supplied by Cheiron
void main()
{
     object oTarget = GetNearestCreature(
          CREATURE_TYPE_PLAYER_CHAR,
          PLAYER_CHAR_IS_PC
     );

     ClearAllActions();
     object oArea = GetArea(oTarget);
     vector vPosition = GetPosition(oTarget);

     float fOrientation = GetFacing(oTarget);
     // this is where AngleToVector shows it's powers!!
     vector vNewPos = AngleToVector(fOrientation); 
     float vX = vPosition.x - vNewPos.x;
     float vY = vPosition.y - vNewPos.y;
     float vZ = vPosition.z;

     vNewPos = Vector(vX, vY, vZ);

     ActionMoveToLocation(
          Location(oArea, vNewPos, fOrientation)
     ); // go stand right behind the PC (if he's still there)
     ActionDoCommand(SetFacing(fOrientation)); // turn towards PC
}

See Also

functions: Vector | VectorToAngle
categories: Type Casting/Conversion Functions


 author: Charles Feduke, editor: Lilac Soul, additional contributor(s): Cheiron, Lilac Soul