Difference between revisions of "User:DavidJCobb/Rotation Library Tutorial"

m
imported>DavidJCobb
(draft)
 
imported>DavidJCobb
Line 18: Line 18:
<pre>Scriptname CobbOrientationTest extends ObjectReference
<pre>Scriptname CobbOrientationTest extends ObjectReference


Import AtronachCrossingRotationLibrary
Import AtronachCrossingLibraryRotations
Import Utility
Import Utility


;
; These arrays define the position and rotation of the child object RELATIVE
; to this object. These would be the child's position and rotation if this
; object were placed at (0, 0, 0) and set to rotation (0, 0, 0).
;
Float[] Property pfPositionOffset Auto
Float[] Property pfPositionOffset Auto
Float[] Property pfRotationOffset Auto
Float[] Property pfRotationOffset Auto
ObjectReference Property pkChildObject = None Auto Hidden
;
; This is the object that we'll be placing.
;
ObjectReference Property pkChildObject = None Auto


Event OnInit()
Event OnInit()
Line 34: Line 42:


Function RunTest()
Function RunTest()
   SetAngleZ( RandomInt(0, 359) as float )
{Randomize this object's rotation, and then reposition and rotate the child object to match it.}
  SetAngleY( RandomInt(0, 359) as float )
   SetAngle( RandomInt(0, 359) as float, RandomInt(0, 359) as float, RandomInt(0, 359) as float )
  SetAngleX( RandomInt(0, 359) as float )
   UpdateChildPosition()
   UpdateChildPosition()
EndFunction
EndFunction


Function UpdateChildPosition()
Function UpdateChildPosition()
{Disable physics on the child object, and then position and rotate it to keep it in line with this object.}
   If pkChildObject
   If pkChildObject
       pkChildObject.SetMotionType(4)
       pkChildObject.SetMotionType(4)
       MoveObjectRelativeToObject(pkChildObject, Self, fPosition, fRotation)
       MoveObjectRelativeToObject(pkChildObject, Self, pfPositionOffset, pfRotationOffset)
   EndIf
   EndIf
EndFunction</pre>
EndFunction</pre>
Line 49: Line 57:
Now go to any cell (or make your own) and add the new statue to it; place the statue at (0, 0, 0) and do not rotate it. Then, add a Dragon Priest Mask to the cell, and position and rotate it so that it rests on top of the statue's face. Write down the mask's coordinates and rotation.
Now go to any cell (or make your own) and add the new statue to it; place the statue at (0, 0, 0) and do not rotate it. Then, add a Dragon Priest Mask to the cell, and position and rotate it so that it rests on top of the statue's face. Write down the mask's coordinates and rotation.


Edit the placed statue's script properties. Set ''pfPositionOffset'' to an array containing the mask's coordinates; set ''pfRotationOffset'' to an array containing the mask's rotation; and set ''pkChildObject'' to the placed mask itself.
Edit the base activator's script properties. Set ''pfPositionOffset'' to an array containing the mask's coordinates; set ''pfRotationOffset'' to an array containing the mask's rotation. Edit the placed activator's properties as well: set ''pkChildObject'' to the placed mask itself.
Anonymous user