SetFacing

From NWN Lexicon
Jump to: navigation, search



SetFacing(float)

Sets the object to face a certain direction.

void SetFacing(
    float fDirection
);

Parameters

fDirection

A floating point number that represents the direction to face. See description for additional details.


Description

Causes the caller of this function to face fDirection.

There are some predefined constants for a direction:
DIRECTION_EAST = 0.0
DIRECTION_NORTH = 90.0
DIRECTION_WEST = 180.0
DIRECTION_SOUTH = 270.0



Remarks

This action is often used for creatures. It also works for dynamic placeables, but small changes (less than 20 degrees) may not be rendered visually, even though the new facing (as determined by GetFacing) is exactly right.

Note that GetFacing will correctly return the facing to the nearest degree from 1.62.


Known Bugs

There are issues with setting the facing of sitting creatures.


Version

1.22

Example

// Used in the OnSpawn of a creature to set 
// their facing to a random direction.
main()
{
   // Get a random direction from 0 to 360
   float fDirection = IntToFloat(Random(361));
 
   SetFacing(fDirection);
}

See Also

functions: 

SetFacingPoint

constants: 

DIRECTION_* Constants



 author: Tom Cassiotis, editor: Jasperre