in theory very simple script to make an item hover perpetual

Post » Sun Aug 18, 2013 3:01 pm

I've noticed a few items in game until encountering collision float in the air, and I mean moving very very slightly back and fourth. Does anyone know of a way to script an object to do this indefinitely? (The reason being, I'm making a cave inhabited by mages, and if I can make some items just perpetually move say, repeatedly move 3 inches up then three inches down then back up and so on forever, it would make the place look a lot more magical). I think some script that would make them move back and fourth on the Z axis. The idea isn't for the objects to be interacted with, but rather just to add to the atmosphere the same way trees in vanilla Skyrim do.
User avatar
Kayla Keizer
 
Posts: 3357
Joined: Tue Dec 12, 2006 4:31 pm

Post » Sun Aug 18, 2013 12:11 pm

Ooooh... I've been looking for the same thing.
I'll just tag along here and hope to see an answer that's usefull. =)
User avatar
Celestine Stardust
 
Posts: 3390
Joined: Fri Dec 01, 2006 11:22 pm

Post » Sun Aug 18, 2013 1:32 am

Here's a cleaned-up version of a script I have used to do this:

Spoiler

Scriptname vutil_FloatyObjectScript 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 = 20.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 = 40.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's very basic movement, you may want to modify it to do things like taper velocity at the top and bottom of the drift or add a spin, etc. The default values make the object the script is attached to slowly drift up and down about a foot from their starting point. Hope it helps!
User avatar
Lily
 
Posts: 3357
Joined: Mon Aug 28, 2006 10:32 am

Post » Sun Aug 18, 2013 5:03 am


I experimented a bit with the script, first to items, then to moveable static, then to static, then to a custom ID activator with the trap script removed. None of them worked. Am I doing something wrong? I added the script and it compiled perfectly, but the objects are just staying still. is there some other thing I must do?

Edit: Nevermind the objects are moving now.
User avatar
Tanya Parra
 
Posts: 3435
Joined: Fri Jul 28, 2006 5:15 am

Post » Sun Aug 18, 2013 2:11 am

Yeah, it probably won't work on unmodified statics, but should work on pretty much any other object set to Motion_Keyframed and can have a script attached to it. You should be able to make it work on Havok objects as well by changing their motion type to Keyframed right after the Is3DLoaded loop in the OnLoad event.
User avatar
Penny Flame
 
Posts: 3336
Joined: Sat Aug 12, 2006 1:53 am

Post » Sun Aug 18, 2013 9:23 am

I'm bringing this old thread back to live, since I last worked with this (and followed this thread), I can't seem to figure how to make this work?

Not very used to scripts, so I need to know how to do this - like: Apply script to object X and etc.

I've made a copy of GrandSoulGem and called it LorThal_FlyingGem and I need it to hover up and down and rotate (I'll need this effect for more objects), but applying the script to an object like the Gem crashes my CK.

What do I do?

Cheers!

User avatar
Yvonne
 
Posts: 3577
Joined: Sat Sep 23, 2006 3:05 am

Post » Sun Aug 18, 2013 1:27 am

Found no problem using this script.

I attached it to the grand soul gem (and a modified version) like every other script (right click, edit, scripts tab, add)

The only thing I had to change to make items float was to add a single line to the OnLoad event:

self.SetMotionType(Motion_Keyframed)
User avatar
Hearts
 
Posts: 3306
Joined: Sat Oct 20, 2007 1:26 am


Return to V - Skyrim