Jump to content

Any Good Rotation Scripts out there?


Zorkaz

Recommended Posts

Does anyone have a good rotation script leftover that maybe uses floats?

 

 


Float Property RotationSpeedWaitTime Auto
Float Property RandomZ Auto
Float Property RandomY Auto
Float Property RandomX Auto
Float Property AddonFactorX Auto
Float Property AddonFactorY Auto
Float Property AddonFactorZ Auto


Event OnLoad()
AddonFactorX = Utility.randomfloat (0, 1)
AddonFactorY = Utility.randomfloat (0, 1)
AddonFactorZ = Utility.randomfloat (0, 1)

While self.isenabled()

Utility.wait(RotationSpeedWaitTime)
RandomX = RandomX + AddonFactorX 
RandomY = RandomY + AddonFactorY

RandomZ = RandomZ + AddonFactorZ


self.SetAngle(RandomX, RandomY , RandomZ)
If RandomZ >= 360 
   RandomZ = 0 

Elseif RandomY >= 360
RandomY = 0

Elseif RandomX >= 360
RandomX = 0
EndIf

endwhile



endevent

Event OnUnload()
self.reset()
EndEvent




 

 

I created a slow moving one for asteroids and while it works the game crashes when moving too far away. (In an interior cell)

Link to comment
Share on other sites

https://www.creationkit.com/index.php?title=Spatial_functions_and_snippets

You can probably tweak that for your needs(requires some what advanced knowledge in trig, which I myself don't have). The coordinate system still uses ZYX like in Skyrim.

 

Maybe experiment with OnTimer, or DistanceGreaterThan/LessThan events to turn on/off the operation to prevent the crash when the player's distance is x units away.

 

As its in an interior, you can handle resets with OnCellDetach() and not rely on Unload which may or not fire.

Edited by Rasikko
Link to comment
Share on other sites

I would also use translateto and the corresponding event ontranslationcomplete as puting an infinite loop in the onload event is a very bad idea.

Especially as everytime it loads again it will create another such loop on the same object.

 

With trasnlateto you trigger the first small rotation increment on the 'onload' then the ontranslationcomplete triggers the next one.

Then all you need is an 'is3dloaded' check in that logic to not trigger another rotate when you move out of range.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...