Zorkaz Posted February 17, 2020 Share Posted February 17, 2020 I didn't find a vanilla script or a forum entry, so I'm posting this simple script here for people who want to expand it and look for such a script via google Quote Scriptname HRLLighthouseLightRotation extends ObjectReferenceint zaxis = 0event oncellload()While self.isenabled()self.SetAngle(0.0, 0.0, zaxis)zaxis = zaxis + 1If Zaxis == 360 Zaxis = 0EndIfendwhileendevent I used it on a lighthouse light by the wayOne might add utility.wait (<insert number here>) to make it go slower Link to comment Share on other sites More sharing options...
SKKmods Posted February 17, 2020 Share Posted February 17, 2020 With the zaxis counter constantly incrementing, after a period of time it will overflow (probably at 2,147,483,647). Whilst that is a long way away, publishing unbounded stuff is bad practice when it is simple to manage: If Zaxis == 360 Zaxis = 0 EndIf Link to comment Share on other sites More sharing options...
DiodeLadder Posted February 17, 2020 Share Posted February 17, 2020 You could also use the "RotateHelperDefaultSpin01", and attach ref on it. It's animation based, and comes with a script ready to go. :-) Link to comment Share on other sites More sharing options...
Zorkaz Posted February 17, 2020 Author Share Posted February 17, 2020 Good idea you all, just wanted to have a forum post on this Link to comment Share on other sites More sharing options...
DieFeM Posted February 17, 2020 Share Posted February 17, 2020 (edited) You can also use TranslateTo, I think it can do a smoother movement, and you can adjust the speed with more accuracy.Scriptname Rotate extends ObjectReference Float Property fRotationSpeed = 200.0 Auto Event OnCellLoad() SetMotionType(Motion_Keyframed);some objects need this to move their collision alongside the mesh. RotateOnce() EndEvent Function RotateOnce() TranslateTo(X, Y, Z, GetAngleX(), GetAngleY(), GetAngleZ() + 180, 100.0, fRotationSpeed) EndFunction Event OnTranslationAlmostComplete() RotateOnce() EndEvent Function SetSpeed(Float Speed) fRotationSpeed = Speed EndFunctionI added a SetSpeed function so you change the rotation speed from the console, by clicking on the object that has the script attached and for example:cf setspeed 25Additionally, if you want it to rotate in one of the other angles you just need to set "+ 180" in the angle that you want to rotate the object: Rotate vertically, left to right:TranslateTo(X, Y, Z, GetAngleX(), GetAngleY() + 180, GetAngleZ(), 100.0, fRotationSpeed) Rotate vertically, back to front.TranslateTo(X, Y, Z, GetAngleX() + 180, GetAngleY(), GetAngleZ(), 100.0, fRotationSpeed) The direction of the rotation is almost random, if you want to ensure the rotation direction use +/- 179, it will force the rotation to one side or the other. Edited February 17, 2020 by DieFeM Link to comment Share on other sites More sharing options...
Recommended Posts