Eular Measurements and Rotations.

Hey,

Ok so I’m starting to feel pretty silly. I’m stuck on this for a few hours, and it feels so easy, but I just can’t find the answer.

Eg. Tracking a cubes rotation. I want to continuously track how far the cube has rotated since starting the rotation.

The problem is using get world rotation or transform shows the degrees going from 0 to 90 and the back to 0 before going negative, Which makes sense. Assumably it’s split into 4 quadrants.

But How would I go about calculating total rotation since the beginning?

Thanks for reading :slight_smile:

Update:
I assume I need a variable “Total rotation”, Youd take the chosen axis (Im using pitch currently)

Cant use add, as itll add the total rotation and pitch together costantly just screaming up the numbers.

maybe delta(rotator) somehow.

Could you show your blueprint code? A rotation value actually ranges from -180 to 180.

I apologize, I’ve just deleted it and having another rebuild now. Tbh there wasn’t a lot to show.

I have my cube, and I’m getting its rotation. Using “get world rotation” and exactly right, The returning string as I rotate the cube. is between -180 and 180.

It goes up to 90 degrees and returns to 0 before going negative -90 and back to 0.

But I want to calculate the total rotation its made.

The rotation in world space will give you the rotation in world space. That’s totally expected. If you want to get the difference in rotation, you can simply store the object’s rotation in world space inside a rotator type variable before rotating it, and once it’s rotated, compare the stored rotation value with the actor’s current world rotation by using the Delta Rotator node.

However if you’re smoothly rotating an object and comparing it’s current rotation with a pre-determined starting rotation, to continue getting positive values (181 instead of -179 for example) you can update the stored rotation and after every comparison with the current rotation, you can add the result onto a float type variable (or rotator if you want to get all of the axes)

Hope this helps! :innocent:

Yeah, ah right, OK. I understand the question I’m trying to ask better.

I have a smoothly rotating cube that’s input is decided by a mouse/touch. Using add local rotation.

And Im trying to calculate total degrees rotated as it smoothly spins. This could be both forwards and backwards.

This is kind of a simplified version of what is going on.

So Im figuring out the order between event tick and add local to calculate total degrees rotated.

What’s Event Tick doing there :thinking:

Anyways, I see you’re controlling the rotation with player input. That wasn’t what I meant by smoothly rotating it, this would actually be categorized better with the snappy usage.

Now, you didn’t clarify your objective in your last post but considering the previous ones, I think you wanna get the rotation value in world space in (0, 360) range instead of (-180, 180). If so, you can just get the actor’s rotation as normal, but use a Branch node to check if it’s negative or not and if it is, add 360 onto the result before storing it inside a variable.

Have a variable track it and set component rotation to that value:


In your very case: instead of +1 as above, add what the input node axis spit out. You can then use modulo to calc how many quadrant (or whatever) that is.

I feel I should rephrase everything as I feel Im being confusing.

I have a mouse input that rotates a cube, you can flick the mouse and watch the cube to spin.

I initially used simulate physics for this, which worked well. But When you release the mouse(and 0 was no longer the angular velocity), it throws itself eventually off axis, which was a pain for accuracy.

I cant lock the axis as I need to influence axis with certain types of rotation.

So instead I swapped to this adjusting the rotation with the mouse and the event tick keeps the cube spinning depending on the mouse inputs.

But now I need to calculate how far the cube has spun so I need to swap the 0 to 90 degrees and back to 0 and then inverted -90 and back to 0 (Not sure what this rotation style is called)

for 0-360. So I can calculate when the cube has done a full spin.

This.

Or if anyone knows how to stop simulated physics throwing itself off axis as well lol?

  • constrain it
  • ensure the centre is centred in the modelling mode
  • for complex meshes, with many convex shapes you may need to disable colliders’ mass contribution

I didn’t quite get what you meant by that but since you confirmed that your objective was what I was guessing, this should do the job:


And also

Haven’t tried such a thing but sounds interesting! :grin:

Or even simpler:

1 Like

xD As I feared, I do not understand any of this, lol.

I found the name, someone might have mentioned it already. “Eular angles”. After looking into it, I ended up I think somewhere close to what was being discussed here.

Although it kinda works. It hits about 70 degrees and bounces back again instead of just continuing up to 360 or down.

I think its just the order of the nodes need mixing up.

Let’s start from the scratch :sweat_smile:

It’s just this:

If the float value (pitch, in your case) is less than 0, add 360 onto it.

To do that, you can get an addition (+) node, plug the pitch value into one of it’s pins, then insert the value “360” into the other pin by typing into it, and set your float type variable to it. If the pitch value was already greater or equal to 0, then just directly set your float type variable to it.

I burst out laughing, xD I think I’m actually going slowly insane. This?

It feels closer xD.
It goes between 282 up to 360 which flips then flips to 0 and goes to 82. And then inverts and goes back down to 0 before flipping and going back to 282.

Basically bouncing between 282 and 82.

While doing what? Rotating about 90 degrees and getting the world / relative rotation? That would be expected. Because the initial rotation of the cube matters in this case. If you want to get the difference in rotation, you’d wanna subtract the initial rotation from the result.

I wish I could figure out gifs so I could just send a gif xD.

It’s the Euler system that’s used that’s just absolutely baffling. Trying to convert the Euler system into just a normal 0-360 scale so I can use it to calculate rotation amount.

Obj. I just want to spin a cube with my mouse and when it does a full 360 degree spin, have it say backflip xD.
And then later maybe insert some specific angles for different spins. and it has to be dynamic to the rotation happening so I cant set it, or preset it. The player might wildly just spin the cube and it needs to calculate how many degrees its spun.

Itd be nice to be able to show the player exactly how many degrees they’ve done before the backflip is hit (360) done.

In my head, it’s so basic. But It’s quite the brickwall.

Hopefully the objective makes sense a bit better, Im going to go apply a straight jacket after battling this today xD.

In that case, you can do it like this:

Here’s the result:

Hope this helps! :innocent:

Thanks for all the help, So I stayed up late banging my head against it. That example I got working with the camera, But I couldn’t replicate the results with pawns.

So I went back to simulate physics as I think It worked better compared to just adding local rotation. I then managed to get it to track with this.

So now I can make adjustments to the power and speed of the adjustments, I can record total degrees used up and down.

BUT I’m a bit back to square one, where my lil guy (Cube man) Spins wildly off axis after a second or 2. So hes either no very well balanced or hes being influenced by something.

I can’t lock the axis as I need to influence them later.

Jump to the very bottom for the implementation of your objective

Absolutely nothing is different in the logic. Here:

Can you show your attempt on implementing the code I provided, along with the outcome?


Why don’t you just add controller yaw & pitch inputs and enable the spring arm to use pawn control rotation like this? :thinking: (Wait I get what you’re trying to do, I’ll edit once again)

Screenshot 2024-12-10 174036


So if you wanna only rotate the mesh and not the camera like this:

The logic would still be the same! You can just play with the threshold value we’ve set up according to the input intensity we got above. Here’s the revised logic with the correct threshold value for my specific multiplier:

And here’s the result:

Sorry, I only just back to this.

I’ve been playing a lot, I apologize for having nothing to show, But Ive been flip-flopping between all sorts to kind of get to grasps with understanding Euler angles and how it relates accurately to degrees rotated.

Baffling system, Eg. a 360 on the Y axis performs a flip. Perfect. If you slightly go off axis, a true full 360 isn’t performed, as you’re no longer doing a perfect Yaxis flip.

So how I imagine for example a cork 540 to be done, 360 on one axis and 180 on another isn’t going to accurately show that in degrees when trying to measure exact degrees.

Here’s where I’m at atm, I’ve tried to replicate yours to align our viewpoints to bring confusion down. (I have a habit of being incredibly confusing at the best of times)

Ive connected the event tick just so It doesnt lose itself when the mouse is unclicked.

A few Questions.
So how come x3?
Is the action value X from the enhanced input action 0.33 of a degree?

What is the clamp for?