Jump to content

Photo

How does the GetAngle() and SetAngle() and rotation of objects in general work?

scripting rotation

  • Please log in to reply
4 replies to this topic

#1
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,896 posts

Good afternoon everybody!

 

I am currently trying to implement a scripted "button".

Basically just an activator (custom mesh) that has a script attached to it that "pushes the button in" when the player activates it.

 

So I need to move an object reference "backwards" from where it is.

 

If the object is placed on a straight wall then that is simple: Just move it on the X or Y axis.

 

But I need to have this button on a sloped wall (for reasons), that wall is also placed at an angle in terms of the Z axis.

 

So I need to move an object reference along its local X Y or Z axis.

Kind of like you can do in the CK, but I need to do it with a script.

 

So a function like this would be cool:

MoveOnLocalAxis(float LocalXMovement, float LocalYMovement, float LocalZMovement)

But there is not function that does something like that, not even F4SE can do something like that.

(I already emailed the F4SE team and asked them if they could maybe implement a function like that)
 

 

So I need to make a script that does the following:

  1. Get the current position of the object
  2. Do some fancy math to figure out the new position
  3. Translate the object to that new position

Simple.

 

Except it isn't.

 

 

To get the "direction" of the local X Y or Z axis I need to know how the game actually handles or represents the "rotation" of an object.

If you edit an object reference in the CK then you have three values (X Y Z rotation) but what do they actually mean?

 

Sure if you just rotate along one axis everything is easy.

But if I tell the game to rotate something to 36° X, 57° Y and 11° Z, how does the game actually handle that?

Does it rotate along the Z axis first, then the Y axis, then the X axis?

Does that even matter?

 

I really hope that somebody with more knowledge about all of this stuff can help me becaue there is no documentation on how exactly this works, so I am really stuck.



#2
pepperman35

pepperman35

    Old hand

  • Members
  • PipPipPip
  • 842 posts

Pretty sure I saw something along these lines on the Skyrim section.  Yes, here it is.  Maybe it would be helpful

 

Local to global rotations - that old chestnut!



#3
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,896 posts

Pretty sure I saw something along these lines on the Skyrim section.  Yes, here it is.  Maybe it would be helpful

 

Local to global rotations - that old chestnut!

Allright, thanks!

That helped a bit.

The skyrim documentation on the ck wiki says this:

  • When rotating an object, it is important to know the order in which the rotation angles are applied. The Z-axis rotation (yaw: north/south/east/west) is applied first, followed by the Y-axis (roll: tilt) and finally the X-axis (pitch: forward/backward).

That helps, I guess ...



#4
pepperman35

pepperman35

    Old hand

  • Members
  • PipPipPip
  • 842 posts

Assuming this is an object (i.e., not a character) that you are wanting to move along a certain axis and/or path, could you not make it an animated nif?



#5
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,896 posts

Assuming this is an object (i.e., not a character) that you are wanting to move along a certain axis and/or path, could you not make it an animated nif?

I don't want to.

 

Unless you know of a good tutorial for custom animated activators (pushbuttons, ...).

 

And besides, I am going to need something like this movement function anyways for something else too, other then simple pushbuttons ...


Edited by YouDoNotKnowMyName, 03 December 2021 - 03:19 AM.






Also tagged with one or more of these keywords: scripting, rotation

IPB skins by Skinbox
Page loaded in: 1.186 seconds