Jump to content

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


Recommended 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.

Link to comment
Share on other sites

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 ...

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...