SetMotionType - ObjectReference

From the CreationKit Wiki
Jump to navigation Jump to search

Member of: ObjectReference Script

Sets the object's havok motion type. This function is widely used as part of the included defaultDisableHavokOnLoad script, which is intended to make physics-enabled objects behave as if they were static.

Syntax[edit | edit source]

Function SetMotionType(int aiMotionType, bool abAllowActivate = true) native


Parameters[edit | edit source]

aiMotionType: New Havok motion type. Allowed values are:

  • Motion_Dynamic = 1: The object will be simulated by havok (fall, etc...). It appears that the engine may automatically set this object to the SphereInertia or BoxInertia motion type.
  • Motion_SphereInertia = 2: "Softened" movement simulation performed using a sphere inertia tensor.
  • Motion_BoxInertia = 3: "Softened" movement simulation performed using a box inertia tensor.
  • Motion_Keyframed = 4: The object will NOT be simulated by Havok (will only move if forced to, through SetPosition() or TranslateTo())
  • Motion_Fixed = 5: This motion type is used primarily for the static elements of a game scene, e.g. the landscape.
  • Motion_ThinBoxInertia = 6: A box inertia motion optimized for thin boxes to have less stability problems.
  • Motion_Character = 7: A specialized motion used for character controllers.


abAllowActivate: If setting the motion type to Dynamic, whether the object should start simulating right away. Otherwise, it will remain in it location until activated (attacked or Z-keyed, both of which don't apply for objects set to keyframed).

  • Default: True


Return Value[edit | edit source]

None.

Examples[edit | edit source]

; Set the rock to no longer be simulated (it will be frozen in place). The following two statements are equivalent:
Rock.SetMotionType(Rock.Motion_Keyframed)
Rock.SetMotionType(4)


; Set the rock to be simulated, but not to move until touched. The following two statements are equivalent:
Rock.SetMotionType(Rock.Motion_Dynamic, false)
Rock.SetMotionType(1, false)


Notes[edit | edit source]

  • When using this function in a script that extends ObjectReference, it is not necessary to prefix Motion_Keyframed and Motion_Dynamic with an ObjectReference property or variable (e.g. Rock), since the these properties are native to the ObjectReference script.
  • If you set an object's motion type to dynamic, it may hang in the air until bumped, even if you pass True as the second argument. To get the object to start falling after having its physics enabled, apply a Havok impulse with a downward force vector (0, 0, 1) and a zero magnitude.

Bugs[edit | edit source]

  • Certain references have 3D meshes that are incompatible with this function. If a NIF has any bhkCollisionObject with flag 8 set (e.g. 137 & 8 == 8), then references using that NIF will show unstable behavior, of which there are two kinds. Once unstable behavior has occurred, it cannot be reverted through normal means, as there is no way to unset a motion type override.
    • In some cases, only part of the mesh moves; for example, a Noble Wardrobe will separate from its door.
    • In other cases, the mesh will not move, but the game engine will believe that it has moved, reporting incorrect position. Most of the game's non-load doors show this behavior.
    • Sometimes, changes can "bleed over" onto other references that use the same mesh, though only for the life of the session. However, references that are directly affected will remain affected, and the problem will be baked into the user's save.
    • The specific problem is that this flag is, for some reason, incompatible with how the game handles references that have the HAVOK_MOVE changeFlag set. ChangeFlags are used to keep track of what data needs to be written to the user's savegame.

See Also[edit | edit source]