The script goes like this.
Scriptname ALectraLevitateScript extends ObjectReference{Object will drift up and down}Import UtilityImport GameBool Property bStartAtBottom = False Auto{Set True if drifting down would cause the object to clip through its starting point}Float Property fVel = 4.0 Auto{Base speed at which to drift}Float Property fDriftX = 0.0 Auto{Random drift along X axis}Float Property fDriftY = 0.0 Auto{Random drift along Y axis}Float Property fDriftZ = 2.0 Auto{How far to drift along Z axis}Float fPosX = 0.0Float fPosY = 0.0Float fPosZ = 0.0Float fAngX = 0.0Float fAngY = 0.0Float fAngZ = 0.0Float fTDriftZ = 0.0Event OnLoad() ;Store object's starting position fPosX = GetPositionX() fPosY = GetPositionY() fPosZ = GetPositionZ() fAngX = GetAngleX() fAngY = GetAngleY() fAngZ = GetAngleZ() If bStartAtBottom ;Set the path center to above the starting point fPosZ += fDriftZ / 2 EndIf ; TranslateTo will fail if object's 3d is not completely loaded While !Is3DLoaded() Wait(0.01) EndWhile UpdateTranslation()EndEvent;Use this instead of OnTranslationComplete, otherwise there will be a pause before the object moves again.Event OnTranslationAlmostComplete() UpdateTranslation()EndEventEvent OnCellDetach() CleanUp()EndEventEvent OnUnload() CleanUp()EndEventFunction UpdateTranslation() Float fCPosZ = GetPositionZ() If fCPosZ < fPosZ ;We are below the center point If fDriftX || fDriftY ; We need to drift X and Y as well TranslateTo(fPosX + RandomFloat(-fDriftX,fDriftX), fPosY + RandomFloat(-fDriftY,fDriftY), fPosZ + (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel) Else ; No X or Y drift, RandomFloat is slow so skip it if we don't need it TranslateTo(fPosX, fPosY, fPosZ + (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel) EndIf Else ;We are at or above the center point If fDriftX || fDriftY ; We need to drift X and Y as well TranslateTo(fPosX + RandomFloat(-fDriftX,fDriftX), fPosY + RandomFloat(-fDriftY,fDriftY), fPosZ - (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel) Else ; No X or Y drift, RandomFloat is slow so skip it if we don't need it TranslateTo(fPosX, fPosY, fPosZ - (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel) EndIf EndIfEndFunctionFunction CleanUp() StopTranslation() ; This should keep the object from getting progressively farther from its starting point if the cell is loaded repeatedly MoveToMyEditorLocation()EndFunction
It works fine for static objects, but it doesn't work for objects that can be put into the players inventory. Strangely enough it worked before for several weeks in the past, but recently this script no longer functions for inventory objects.
The script itself is perfect, but why did it stop working on inventory objects? Was there some change to the game itself or something recently? Any ideas? I'd be very thankful for any help on this baffling issue.