SetObjectVisualTransform(object, int, float)

From NWN Lexicon
Revision as of 17:33, 19 February 2021 by Tinygiant (talk | contribs)
Jump to: navigation, search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.
Sets a visual transform on the given object.
float SetObjectVisualTransform(
    object oObject,
    int nTransform,
    float fValue


Can be any valid Creature, Placeable, Item or Door.
An OBJECT_VISUAL_TRANSFORM_* constant specifying the tranform type to apply
Depends on the transformation to apply.


Sets a visual transform on the given object.

Returns the old/previous value.

If used on a player in a PW setting it is saved to the players BIC on exit, and applied when loaded.


This has several useful applications for both creatures, placeables, items and doors. The item transformations can only occur when it is placed on the ground and has a model (not in a placeable itself).

Placeables must be non-static for this to work on them (the usable flag isn't required). For more information about placeable states see the page.

Creatures transformed retain their appearance.2da values for PERSPACE and CPERSPACE, so a "Enlarged" creature appearance would start to clip into terrain.

Some ideas for potential useful or fun uses of this:

  • Giant area - all placeables are scaled down in size while the player stays the same size. Works especially well in tilesets with little in built terrain
  • Raising from the dead - A creature's Z location can be translated under the map, an animation played and they are gradually "raised" upwards to where Z = 0.0
  • Flying - With some appropriate animation set, a Z translation upwards can make a creature fly.
  • Displacement - Have the character randomly blink around their X, Y location when under the effect of some defensive spells to make it seem as if they're dodging in and out of space.
  • Mad world - Have placeables on ceilings, on walls, or spinning around.

A more advanced usage would be on a non-static placeable that is incredibly large - but would pop in/out of view of the player (Due to the 45M distance range on placeables loading) several versions of the placable could be put at discrete distances that essentially overlap using this command (meaning one at least always visible).

Note the visual transformation cannot be done completely smoothly (seems you can do several a second but not 1 per frame), but it can look reasonable enough for changing up/down size or moving objects around.

This function works only on the object's visual presentation and does not change properties of the object. For example, if a script is used to translate a placeable, the placeable will appear to move to a new position, however, the object's actual position (as retrieved by GetPosition has not changed. Additionally, if a placeable is visually translated, then clicked on to use, the PC object will move to the original position of the placeable, not the translated position. Additionally, this function will translate objects outside the areas boundaries and an invisible object remains at the original location, presenting a potential hazard to navigation/pathfinding issue.




Information icon.png This article is in need of examples. You can help the NWN Lexicon by showing how to use this code effectively.

See Also

functions: GetObjectVisualTransform()
constants: OBJECT_VISUAL_TRANSFORM_* Constant Group

 author: Shadguy