How to stop 'Add Relative Rotation' to a certain value?

Hi! I want to rotate the object by a few stops, like 180 or 360 on the z-axis, but when I tried to get the current value, it gives an unexpected value, from 0 to -180 and then from 180 to 0.
Is there any way to realize these stops?
I don;t want to use timeline with SetRelativeRotation for this.

Perhaps Add Relative Rotation is the wrong tool here. Do tell what the ideal end result it.

You could drive it with a motor:


Or this:

Would produce this, snapping it to the desired angle:


Or replace the node with:

Really depends on the desired end result.

How to stop ‘Add Relative Rotation’ to a certain value?

Not entirely sure what this means.

1 Like

it works with SetActorRotation, but if I put 180 instead of 90, after the first 180 rotation it will return as -180. I want something like 180 first and 360 second.

It works the same with X axis, but for Y something is wrong.

Try the last node I suggested - see how it goes.

1 Like

With AddLocalRotation works the same.

No, no. Use what you wanted here:

Just replace that one node.


Admittedly, you actually never explained how it should work. We can only see that something is wrong. What are we trying to achieve? Press a button and rotate by X degrees? Or hold a button to rotate a bit every frame? Because that’s what your script has and it’s the only thing to go by.

And your last screenshot uses world rotation for a component that is most likely operating in local space. We do not know the hierarchy either.

Sorry, too many unknowns here.


I want to rotate the object by a few stops, like 180 or 360 on the z-axis

It’s this then:

Or is specifically 180 - we want to flip it about?

1 Like

I’m sorry for the misunderstanding, i don’t know exactly how to write either.
I want to press once for a 180 spin and another one for 360.
It’s like your exemple with SetActorRotation, but with 180, not 90 degrees.
I need to rotate the object inside the actor, not rotate the actor itself.

1 Like

I set it up again but it seems to work fine:

Rotating just the comp relative to th actor:

image

Is the anim close enough to what’s needed?

1 Like

This is the problem. Instead of going 360 degrees, it will go backwards.
That’s why I wanted to use Add Local Rotation/ Add Relative Rotation because it rotates completely 360, but I don’t know how to stop when it reaches the threshold of 360 or if you want 180 as well.

So it’s about the direction it goes back?

1 Like

Yes!

1 Like