DirtyDan86 Posted November 6 Share Posted November 6 Hi everyone, I want to rotate a static object 180° in game by pressing a button and rotate it back when pressing again. Actually very simple, but all I found doesn't work for Starfield. I found a YouTube video for Fallout explaining Rotationhelpers and the following script attached. I can compile this one, but it has no effect in game, so I guess the variables are wrong or something? Or is it that the Rotationhelpers in Starfield are different? I can't find a single one that is showing the degrees like the ones in Fallout seem to do. Spoiler Scriptname RotateHelperScript extends ObjectReference ObjectReference Property HingeMarker01 Auto Const ; This is a reference to a RotateHelperDefaults01 ObjectReference Property HingeMarker02 Auto Const ; This is a reference to a RotateHelperDefaults01 ObjectReference Property HingeMarker03 Auto Const ; This is a reference to a RotateHelperDefaults01 ObjectReference Property HingeMarker04 Auto Const ; This is a reference to a RotateHelperDefaults01 Float Property RotateSpeed Auto Const ; This controls the animation speed (1.0 to 20.0) ; This OnActivate event is a fallback incase things don't work, you don't need it here. Event OnActivate(ObjectReference akActivator) Debug.Notification("Something went wrong, event triggered without state") EndEvent ; This is the default state named "Closed", OnActivate will trigger the animation to go to an open state Auto State Closed Event OnActivate(ObjectReference akActivator) GoToState("Busy") ; Set Busy state to prevent retriggers shouldBeOpening(true) ; Animate to open state GoToState("Open") ; Set Open state EndEvent EndState ; This is the state named "Busy", used if the animation takes too long State Busy Event OnActivate(ObjectReference akActivator) Debug.Notification("I'm busy") ; Show a notification EndEvent EndState ; This is the state named "Open", OnActivate will trigger the animation to go to an closed state State Open Event OnActivate(ObjectReference akActivator) GoToState("Busy") ; Set Busy state to prevent retriggers shouldBeOpening(false) GoToState("Closed") ; Set Closed state EndEvent EndState Function shouldBeOpening(bool isOpening) ; Set rotation speed of the animation to each object reference HingeMarker01.SetAnimationVariableFloat("fSpeed", RotateSpeed) HingeMarker02.SetAnimationVariableFloat("fSpeed", RotateSpeed) HingeMarker03.SetAnimationVariableFloat("fSpeed", RotateSpeed) HingeMarker04.SetAnimationVariableFloat("fSpeed", RotateSpeed) ; Determine if the animation should be going to a new position or back to original ; PlayAnimation is used to rotate each marker by a set degree, values can be: ; Play0 (Original position) ; Play30 (Rotate 30 degrees) ; Play45 (Rotate 45 degrees) ; Play90 (Rotate 90 degrees) ; Play180 (Rotate 180 degrees) if (isOpening) HingeMarker01.PlayAnimation("Play180") HingeMarker02.PlayAnimation("Play30") HingeMarker03.PlayAnimation("Play90") HingeMarker04.PlayAnimation("Play90") else ; Return to original position HingeMarker01.PlayAnimation("Play0") HingeMarker02.PlayAnimation("Play0") HingeMarker03.PlayAnimation("Play0") HingeMarker04.PlayAnimation("Play0") endIf EndFunction Another one is from Darkfox and I'd love to use it as it's very versatile, but it's for Skyrim and I can't even compile it in Starfield CK: Spoiler Scriptname DF_Script_TranslateObject extends ObjectReference {Move a static object to specified coordinates in a cell or to the location of another reference.} ;Original script created by Darkfox127 ;Any potential problems which may arise from this script being changed from the original are the sole responsibility of the mod author making the changes. Bool Property MoveToRef = True Auto {Sets the type of translation. True will translate the object to a reference, wheereas false will translate to specific coordiantes. Default = True} Float Property PosX1 Auto {One of the position variables for the translation} Float Property PosY1 Auto {One of the position variables for the translation} Float Property PosZ1 Auto {One of the position variables for the translation} Float Property RotX1 Auto {One of the rotation variables for the translation} Float Property RotY1 Auto {One of the rotation variables for the translation} Float Property RotZ1 Auto {One of the rotation variables for the translation} Float Property PosX2 Auto {One of the position variables for the translation} Float Property PosY2 Auto {One of the position variables for the translation} Float Property PosZ2 Auto {One of the position variables for the translation} Float Property RotX2 Auto {One of the rotation variables for the translation} Float Property RotY2 Auto {One of the rotation variables for the translation} Float Property RotZ2 Auto {One of the rotation variables for the translation} Float Property RotationVal Auto {The amount you want to rotate the object by.} Float Property SpeedVal Auto {The speed you want the object to be moved.} Float Property Time Auto {The amount of seconds until the object reaches its target. This must be accurate as not to affect the state check for if the object is currently moving.} GlobalVariable Property StateGlobal Auto {The global for the current state that the object is in. Useful for creating things like lifts with multiple activator buttons.} ObjectReference Property TranslateRef Auto {The object to move. Must have the correct NIF settings and be a moveable static.} ObjectReference Property LocationRef Auto {The reference to move your object to. This can be a copy of the object you have or an xmarker sitting in the relevant coordinates.} Sound Property SFX Auto {The sound effect to play while the object is moving. This should be a looping sound that the script will stop after the speicifed time has elapsed.} Sound Property SFX_End Auto {The sound effect to play at the end of the object's translation.} String Property BUSYMSG Auto {The notification to show if the object is currently moving.} Event OnInit() GoToState("Stationary") EndEvent State Stationary ; The object is currently not moving and translation can be started. Event OnActivate(ObjectReference akActionRef) If MoveToRef == True ;debug.notification("Movement Started - 1") If StateGlobal.GetValue() == 0 ;debug.notification("Position One") GoToState("Moving") StateGlobal.SetValue(1) Int SoundInstance = SFX.Play(Self) TranslateRef.TranslateToRef(LocationRef, SpeedVal, RotationVal) Utility.Wait(Time) Sound.StopInstance(SoundInstance) Utility.Wait(0.2) SFX_End.Play(Self) GoToState("Stationary") Else ;debug.notification("Position Two") GoToState("Moving") StateGlobal.SetValue(0) Int SoundInstance = SFX.Play(Self) TranslateRef.TranslateTo(PosX1, PosY1, posZ1, RotX1, RotY1, RotZ1, SpeedVal, RotationVal) Utility.Wait(Time) Sound.StopInstance(SoundInstance) Utility.Wait(0.2) SFX_End.Play(Self) GoToState("Stationary") EndIf Else ;debug.notification("Movement Started - 2") If StateGlobal.GetValue() == 0 ;debug.notification("Position One") GoToState("Moving") StateGlobal.SetValue(1) Int SoundInstance = SFX.Play(Self) TranslateRef.TranslateTo(PosX2, PosY2, posZ2, RotX2, RotY2, RotZ2, SpeedVal, RotationVal) Utility.Wait(Time) Sound.StopInstance(SoundInstance) Utility.Wait(0.2) SFX_End.Play(Self) GoToState("Stationary") Else ;debug.notification("Position Two") GoToState("Moving") StateGlobal.SetValue(0) Int SoundInstance = SFX.Play(Self) TranslateRef.TranslateTo(PosX1, PosY1, posZ1, RotX1, RotY1, RotZ1, SpeedVal, RotationVal) Utility.Wait(Time) Sound.StopInstance(SoundInstance) Utility.Wait(0.2) SFX_End.Play(Self) GoToState("Stationary") EndIf EndIf EndEvent EndState State Moving ; The object is currently moving and translation cannot yet be started. Event OnActivate(ObjectReference akActionRef) debug.notification(BUSYMSG) Return EndEvent EndState If anyone could tell me how I could make this usable in Starfield OR tell me a simple and easy script to rotate and rotate back an object by button activation, I'd greatly appreciate it. Link to comment Share on other sites More sharing options...
LarannKiar Posted November 7 Share Posted November 7 This script would rotate the reference the script is attached to immediatelly (without visible translation). Scriptname RotateHelperScript extends ObjectReference Const ; attach this script to your Static reference, so the ObjectReference of the Static base form Float Property fDegrees = 180.0 Auto Const Event OnActivate(ObjectReference akActionRef) If akActionRef = Game.GetPlayer() ; player activated this Static reference Float fOriginalAngleZ = Self.GetAngleZ() Self.SetAngleZ(fOriginalAngleZ + fDegrees) EndIf EndEvent Link to comment Share on other sites More sharing options...
DirtyDan86 Posted November 7 Author Share Posted November 7 @LarannKiar Thank you very much for the help. Unfortunately I'm getting the error "no viable alternative at input '=' " when trying to compile the script. And I think I didn't express myself properly, because what I'm looking for would actually be a translation and at best being able to set the rotation speed. I want to use it for a (decorational) ship weapon that I can tilt out of the top of the hab with a slow animation by button press and tilt it back to its base with another button press. So the 2 scripts I posted above would do that perfectly (I guess). I just don't know enough about scripting to know how to change them to work in Starfield - OR how to use your script and add translation and rotation speed. Link to comment Share on other sites More sharing options...
Recommended Posts