SetFacingPoint(vector)

From NWN Lexicon
Jump to navigationJump to search

Sets the object to face the direction of a vector.

void SetFacingPoint(
    vector vTarget,
    object oObject = OBJECT_SELF
);

Parameters

vTarget
The vector to have the object face.
oObject
The object to set the facing of (default: OBJECT_SELF).

Description

Cause oObject to face vTarget.

Functions GetPosition and GetPositionFromLocation will provide vectors that can be used as parameters to this function.


Version

This function was updated in 1.89.8193.37 of NWN:EE. VM: Added oObject parameter to SetFacingPoint().


Example

//Make the caller face oTarget
void SetFacingObject(object oTarget)
{
    vector vFace = GetPosition(oTarget);
    SetFacingPoint(vFace);
}

void main()
{
    //Example of use: Caller faces the nearest PC:
    object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);

    if (GetIsObjectValid(oPC)) SetFacingObject(oPC);
}

See Also

functions: 

SetFacing



 author: Tom Cassiotis, editor: Lilac Soul