TranslateTo - ObjectReference

From the CreationKit Wiki
Revision as of 11:38, 10 November 2012 by imported>Perdev (See also Spatial functions and snippets)
Jump to navigation Jump to search

Member of: ObjectReference Script

Makes the object translate to the passed in position and orientation at the given speed.

Syntax

Function TranslateTo(float afX, float afY, float afZ, float afAngleX, float afAngleY, float afAngleZ, float afSpeed, \
  float afMaxRotationSpeed = 0.0) native

Parameters

  • afX: Position along the X axis (Absolute world coordinates).
  • afY: Position along the Y axis (Absolute world coordinates).
  • afZ: Position along the Z axis (Absolute world coordinates).
  • afAngleX: Destination X Angle (Absolute world rotation).
  • afAngleY: Destination Y Angle (Absolute world rotation) (rarely used).
  • afAngleZ: Destination Z Angle (Absolute world rotation).
  • afSpeed: Movement Speed.
  • afMaxRotationSpeed: Maximum rotation Speed (default is 0 to mean "don't clamp the rotation speed") - Negative values cause unpredictable rotation.

Return Value

None.

Examples

; Translate the bird slowly to 0,0,0 with a rotation of 90,90,90
Bird.TranslateTo(0.0, 0.0, 0.0, 90.0, 90.0, 90.0, 1.0)


; Translate the bird slowly to 0,0,0 with a rotation of 90,90,90 with a max rotation speed of 10
Bird.TranslateTo(0.0, 0.0, 0.0, 90.0, 90.0, 90.0, 1.0, 10.0)

Tips

A movement speed parameter (afSpeed) of 1 is extremely slow - nearly imperceptible to the human eye. Starting at a an afSpeed of 100 and working up or down towards the desired speed is recommended.

Notes

  • The movement speed is in units per second.
  • The rotation speed is in degrees per second.
  • afMaxRotationSpeed equal to 0 means that the object will reach the target rotation when it reaches the target position.
  • It is not possible to cause the object to rotate faster than it would with afMaxRotationSpeed equal to 0. (Cannot reach target rotation before target position.)
  • The OnTranslationComplete event will fire when the object reaches both the target position and target rotation.
  • The OnTranslationAlmostComplete event can fire even when the target rotation is far from being reached.

Collision boxes, bugs and other oddities

The collision "boxes" may not be updated after using this function. Here are some of the observations reported on the forums. (source)

  • The collision box is property updated for moveable statics.
  • The collision box is not moved for other static objects. To fix this the object must be declared as a MoveableStatic and its mesh must have the bhkRigidBody settings corrected (see this post).
  • The collision box is voided for actors (but they will still collide with the ground). They will go through other actors, activators, etc.


Besides of that, a few bugs and oddities have been reported:

  • Using havok collision in an activator then trying to translate it doesn't work... it just sits there motionless.
  • You can however translate an enabled activator when it has no 3D... meaning you can do it from ANYWHERE at any time - as long as it was enabled (and a slight wait or other function afterwards).
  • The function does not work on MiscItems (presumably for the same reason). SetPosition - ObjectReference works though.
  • You cannot translate something that is disabled (or was just enabled). You will get a no3D error.

See Also