Difference between revisions of "Talk:SetPosition - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Fg109
imported>Fg109
Line 4: Line 4:
We know that every object has its own local origin.  When the engine renders an object, the model is rendered at the object's origin.  When we move an object using the various functions that change position and rotation, we are updating the coordinates of its local origin.
We know that every object has its own local origin.  When the engine renders an object, the model is rendered at the object's origin.  When we move an object using the various functions that change position and rotation, we are updating the coordinates of its local origin.


However, there is a discrepancy with objects that are dropped manually (ie not from using the [[DropObject_-_ObjectReference|DropObject]] function) from inventory.  A second local origin is created and this second origin is what is used instead when the [[SetPosition_-_ObjectReference|SetPosition]], [[SetAngle_-_ObjectReference|SetAngle]], and [[MoveTo_-_ObjectReference|MoveTo]] functions (and possibly the various Translate functions as well) are called on the object.  However, the various get position functions and the X, Y, Z object reference properties return values from the object's first local origin.
However, there is a discrepancy with objects that are dropped manually (ie not from using the [[DropObject_-_ObjectReference|DropObject]] function) from inventory.  A second local origin is created and this second origin is what is used instead when the [[SetPosition_-_ObjectReference|SetPosition]], [[SetAngle_-_ObjectReference|SetAngle]], and [[MoveTo_-_ObjectReference|MoveTo]] Papyrus functions (and possibly the various Translate functions as well) are called on the object.  However, the various get position functions and the X, Y, Z object reference properties return values from the object's first local origin.


For example, a torch's second local origin is offset from its first local origin by:
For example, a torch's second local origin is offset from its first local origin by:
Line 14: Line 14:
<source lang="papyrus">TorchRef.SetPosition(0, 0, 0)</source>
<source lang="papyrus">TorchRef.SetPosition(0, 0, 0)</source>


then we get the values (1.218338, -20.904724, 1.214581) when we call the get position functions from it.  Similarly, if we use
then we get the values (1.218338, -20.904724, 1.214581) when we call the get position functions on it.  Similarly, if we use


<source lang="papyrus">TorchRef.MoveTo(TorchRef)</source>
<source lang="papyrus">TorchRef.MoveTo(TorchRef)</source>

Revision as of 10:21, 2 May 2012

Dropped Objects

NOTE: My explanation is pure guesswork in order to explain results of my testing.

We know that every object has its own local origin. When the engine renders an object, the model is rendered at the object's origin. When we move an object using the various functions that change position and rotation, we are updating the coordinates of its local origin.

However, there is a discrepancy with objects that are dropped manually (ie not from using the DropObject function) from inventory. A second local origin is created and this second origin is what is used instead when the SetPosition, SetAngle, and MoveTo Papyrus functions (and possibly the various Translate functions as well) are called on the object. However, the various get position functions and the X, Y, Z object reference properties return values from the object's first local origin.

For example, a torch's second local origin is offset from its first local origin by:

(1.218338, -20.904724, 1.214581)

This means if we use

TorchRef.SetPosition(0, 0, 0)

then we get the values (1.218338, -20.904724, 1.214581) when we call the get position functions on it. Similarly, if we use

TorchRef.MoveTo(TorchRef)

we will find that the torch has moved (1.218338, -20.904724, 1.214581) units from itself. --Fg109 10:57, 2 May 2012 (EDT)