Difference between revisions of "ApplyHavokImpulse - ObjectReference"

→‎Notes: Zero magnitude works!
imported>Perdev
(Adding a note for bugs.)
imported>DavidJCobb
(→‎Notes: Zero magnitude works!)
 
(2 intermediate revisions by 2 users not shown)
Line 46: Line 46:


== Notes ==
== Notes ==
* While the graphics and collision boxes are correctly moved by this function, [[GetPositionX - ObjectReference|GetPosition]] and [[GetAngleX - ObjectReference|GetAngle]] will return the old position. A workaround is to have a dummy, invisible, object and use MoveToNode to move it to one of your real object's nodes, then get the position of your dummy object. [http://forums.bethsoft.com/topic/1416758-addhavokballandsocketconstraint-questions/page__view__findpost__p__21667888 (source)]
This function correctly moves the graphics and collision geometry, but the object is still considered to be on its old position. This creates a few problems:
* A side-effect of the previous bug is that if your object's original position is now a few cells away from the player, it will be unloaded by the game even if its graphics and collision box are close to the player. A workaround is to periodically update the position of your ship through [[SetPosition - ObjectReference|SetPosition]].
* If you use SetPosition or MoveTo on the object, it will blink (return to its original position, then to its new position again).
* If your object's original position is now a few cells away from the player, it will be unloaded by the game even if its graphics and collision box are close to the player. A workaround is to periodically translate your object to "self" through [[TranslateToRef - ObjectReference|TranslateToRef]]. This will not translate the mesh and collision geometry. However, if the translation completes, the position will be updated and you will see the object's mesh blink. To address this, you need to use [[OnTranslationAlmostComplete - ObjectReference|OnTranslationAlmostComplete]] and dynamically adjust the speed so that your object never reach itself.
* [[GetPositionX - ObjectReference|GetPosition]] and [[GetAngleX - ObjectReference|GetAngle]] will return the old position. If you need those informations, a workaround is to have a dummy, invisible, object and use MoveToNode to move it to one of your real object's nodes, then get the position of your dummy object. [http://forums.bethsoft.com/topic/1416758-addhavokballandsocketconstraint-questions/page__view__findpost__p__21667888 (source)]
 
Aside from that, this function will fail and throw a Papyrus warning if the reference has no 3D or if a zero-length force vector is used. Otherwise, the force vector will be normalized before the force is applied. A zero magnitude is permitted and force will still be applied (i.e. you won't displace the object, but you'll trigger Havok settling and any other side-effects of it being bumped).


== See Also ==
== See Also ==
*[[ObjectReference Script]]
*[[ObjectReference Script]]
Anonymous user