Zorkaz Posted March 11, 2021 Share Posted March 11, 2021 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 More sharing options...
Evangela Posted March 11, 2021 Share Posted March 11, 2021 (edited) https://www.creationkit.com/index.php?title=Spatial_functions_and_snippetsYou 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 March 12, 2021 by Rasikko Link to comment Share on other sites More sharing options...
PJMail Posted March 11, 2021 Share Posted March 11, 2021 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 More sharing options...
niston Posted March 12, 2021 Share Posted March 12, 2021 Attached is David J. Cobb's rotation library. EDIT: Didn't attach. Find it here: https://filebin.net/z6agocnhqpngf3vg Link to comment Share on other sites More sharing options...
pepperman35 Posted March 12, 2021 Share Posted March 12, 2021 I always thought it would be cool to have a rotation script attached to a statue that turned (followed you) as you went by. Link to comment Share on other sites More sharing options...
Recommended Posts