User:DavidJCobb/Rotation Library Tutorial

From the CreationKit Wiki
< User:DavidJCobb
Revision as of 23:17, 23 August 2014 by imported>DavidJCobb (draft)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Creating the Dibella Statue

In the Object Window, filter to Activators. Right-click in the list pane and select "New." Fill out the dialog box as shown below:

Name
Orientation Demo
Model
Clutter\Statues\StatueDibella.nif
Activate Text
Perform Random Test
Obstacle
Checked.
Ignored by Sandbox
Checked.

Now, add the following script to it:

Scriptname CobbOrientationTest extends ObjectReference

Import AtronachCrossingRotationLibrary
Import Utility

Float[] Property pfPositionOffset Auto
Float[] Property pfRotationOffset Auto
ObjectReference Property pkChildObject = None Auto Hidden

Event OnInit()
   UpdateChildPosition()
EndEvent

Event OnActivate(ObjectReference akActionRef)
   RunTest()
EndEvent

Function RunTest()
   SetAngleZ( RandomInt(0, 359) as float )
   SetAngleY( RandomInt(0, 359) as float )
   SetAngleX( RandomInt(0, 359) as float )
   UpdateChildPosition()
EndFunction

Function UpdateChildPosition()
   If pkChildObject
      pkChildObject.SetMotionType(4)
      MoveObjectRelativeToObject(pkChildObject, Self, fPosition, fRotation)
   EndIf
EndFunction

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.