antstubell Posted October 24, 2019 Share Posted October 24, 2019 So I'm just geting to grips with Pos. and wrote a small script which as usual brain says "Huh. Don't get it."Here's the script that does nothing at the moment but sets up the structure. it compiles and saves - no problem. Bool Property MoveToRef = True AutoFloat Property RotationVal AutoFloat Property SpeedVal AutoFloat Property Time AutoFloat Property Pause AutoGlobalVariable Property StateGlobal AutoObjectReference Property EnPreMove1 Auto; steamObjectReference Property EnPreMove2 AutoObjectReference Property DisPostMove AutoObjectReference Property EnPostMove AutoObjectReference Property TranslateRef AutoObjectReference Property LocationRef AutoObjectReference Property SndMarker AutoObjectReference Property SndMarker0 AutoSound Property SFX AutoSound Property PreMovementSFX AutoSound Property SFX_End AutoString Property BUSYMSG AutoEvent OnInit()Float CurrentAngleX = TranslateRef.GetAngleX(); get turn left right angleFloat CurrentAngleY = TranslateRef.GetAngleY(); get rotate left right angleFloat CurrentAngleZ = TranslateRef.GetAngleZ(); get up down angleFloat CurrentPosX = TranslateRef.GetPositionX(); get X co-ordsFloat CurrentPosY = TranslateRef.GetPositionY(); get Y co-ordsFloat CurrentPosZ = TranslateRef.GetPositionZ(); get Z co-ordsGoToState("Stationary")EndEventState Stationary ;The object is currently not moving and translation can be started.Event OnActivate(ObjectReference akActionRef)GoToState("Stationary")EndEventEndState Now I add a TranslateTo like this... Bool Property MoveToRef = True AutoFloat Property RotationVal AutoFloat Property SpeedVal AutoFloat Property Time AutoFloat Property Pause AutoGlobalVariable Property StateGlobal AutoObjectReference Property EnPreMove1 Auto; steamObjectReference Property EnPreMove2 AutoObjectReference Property DisPostMove AutoObjectReference Property EnPostMove AutoObjectReference Property TranslateRef AutoObjectReference Property LocationRef AutoObjectReference Property SndMarker AutoObjectReference Property SndMarker0 AutoSound Property SFX AutoSound Property PreMovementSFX AutoSound Property SFX_End AutoString Property BUSYMSG AutoEvent OnInit()Float CurrentAngleX = TranslateRef.GetAngleX(); get turn left right angleFloat CurrentAngleY = TranslateRef.GetAngleY(); get rotate left right angleFloat CurrentAngleZ = TranslateRef.GetAngleZ(); get up down angleFloat CurrentPosX = TranslateRef.GetPositionX(); get X co-ordsFloat CurrentPosY = TranslateRef.GetPositionY(); get Y co-ordsFloat CurrentPosZ = TranslateRef.GetPositionZ(); get Z co-ordsGoToState("Stationary")EndEventState Stationary ;The object is currently not moving and translation can be started.Event OnActivate(ObjectReference akActionRef)TranslateRef.TranslateTo(CurrentPosX, CurrentPosY, CurrentPosZ, CurrentAngleX, CurrentAngleY, CurrentAngleZ, SpeedVal, RotationVal)GoToState("Stationary")EndEventEndState (41,25): variable CurrentPosX is undefinedand Y and Z and so on - every one.Not getting it. Link to comment Share on other sites More sharing options...
Evangela Posted October 24, 2019 Share Posted October 24, 2019 (edited) You declared them in OnInit instead of OnActivate, it cannot see those variables for they are made private to OnInit.By the way, those are what they are, positions in a certain cell. If you want actual coordinates, yes you will need some math. (I didn't bother with Z but just add z array etc if you want that). It's not necessary and probably wont work as expected for movement functions, since they are expecting positions, but yeah here you go: Int[] Function GetCellCoordinates(ObjectReference akRef) ; Returns an array of this reference\s cell coordinates. int posX = akRef.GetPositionX() as int int posY = akRef.GetPositionY() as int if (posX < 0) posX = (posX / 4096) - 1 else posX = posX / 4096 endif if (posY < 0) posY = (posY / 4096) - 1 else posY = posY / 4096 endif Int[] CellCoordinates = new Int[2] CellCoordinates[0] = posX CellCoordinates[1] = posY return CellCoordinates EndFunction Edited October 24, 2019 by Rasikko Link to comment Share on other sites More sharing options...
antstubell Posted October 24, 2019 Author Share Posted October 24, 2019 The reason behind getting the co-ordinates of an object is based on this - watch video and you will see where my issue lies. https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2151479&parId=B60C11D037429D8E%21191&o=OneUp As seen in the video I am using a translateto script, 2 in fact one for up/down and one for left/right which are placed on triggers. This works fine. But... the translations have fixed positions to translate to. The Up/down rotates through the X axis. left/right through the Z axis. For simplicity lets say 90 degrees is the amount I want to move the skull. When player first activates skull and for example chooses Up/Down the skull translates from it starting co-ordinates (set in properties) AngleX1,AngleY1,AngleZ1 to its Up co-ordinates (set in properties) AngleX2,AngleY2,AngleZ2. A global is now set which records 'Skull is in Up position' so if player selects Up/Down again it translates the opposite way. Same for left/right. The 2 scripts are assuming the starting co-ords. are correct regardless of where the skull has rotated to. As you see in the video this messes up the correct translation, sometimes it won't translate at all or move through a diagonal (which ain't so bad but does not follow what the option says).I guess you can see what is wrong in the video. So my idea was "I need to get the current rotation of the skull, tell the script where it is and from there depending if Up/Down Left/Right is chosen, rotate the skull through 90 degrees." This sounded fine - hence my preoccupation of getting the current rotation. Eventually I though "This could present the situation where the skull could be completely rotated. Can't have that!" So next thought was whichever option is chosen skull will only rotate, through X or Z axis +/- 90 degrees so if player chose Left/Right and again Left/Right the first time Left/Right is selected it goes Right 90 degrees but the second time it goes Left 90 degrees. Same for Up/Down. Both case 90 degrees always being the maximum rotation.Finally, the reason for all this rotating is player has to set the skull in a specific position left, right, up or down then 2 other skulls have to be set in correct positions. When all 3 skulls are in their correct positions, script needs to check this by if GetAngleX() = 90 && GetAngleX() = (I'm guessing this scripting is wrong too) then Do Stuff.Long winded I know but I hope I got the idea across.Thanks. Link to comment Share on other sites More sharing options...
Evangela Posted October 25, 2019 Share Posted October 25, 2019 (edited) Yeah I see that it wont rotate downwards like you want it. Maybe will need some trig for this but that's out of my scope. I do know that Skyrim rotation is left handed ZYX. Edited October 25, 2019 by Rasikko Link to comment Share on other sites More sharing options...
antstubell Posted October 25, 2019 Author Share Posted October 25, 2019 Could you show me how to parse a condition that says...If 'the skull's' X rotation is 'value'Do something here I'll work on the rest of the script trying to get rotation working correctly.Thanks. Link to comment Share on other sites More sharing options...
antstubell Posted October 25, 2019 Author Share Posted October 25, 2019 I worked it out. Float CurrentAngleX = TranslateRef.GetAngleX(); get turn left right angleif (CurrentAngleX == -90)debug.notification("Looking Right")Endif But not seeing notification. Link to comment Share on other sites More sharing options...
antstubell Posted October 25, 2019 Author Share Posted October 25, 2019 Okay for some reason axis-I-sis are not what I expected them. X appears to be Z but... whatever.Sorted out my check skull rotation script. This is the function that checks it. Function CheckAngleZ()Utility.wait(4.0); allow time for translation to finishFloat CurrentAngleZ = TranslateRef.GetAngleZ(); get turn left right angleif (CurrentAngleZ == AngleValue)debug.notification("Looking Right. Global is 1")Skull01Set.SetValue(1); skull1 is in placeElseIf (CurrentAngleZ != AngleValue)debug.notification("Nope. Global is 0")Skull01Set.SetValue(0); skull1 is NOT in placeEndifEndFunction Link to comment Share on other sites More sharing options...
Evangela Posted October 25, 2019 Share Posted October 25, 2019 (edited) As I told you, Skyrim uses left handed rotation(I put it in simple terms, but it's really left intrinsic). This means the rotation is not the real world order of XYZ, but the reverse. Thus, when an object is rotating left or right, it is rotating on the Z axis, not the X. Edited October 25, 2019 by Rasikko Link to comment Share on other sites More sharing options...
Recommended Posts