Clamp rotation

Hey there! I was wondering if there is a way to clamp rotations. I want to create a function where you input a rotation and the rotation limits (x,y,z rotation limits) and the function returns the rotation clamped within the angle limits.

the node you are looking for is … Clamp

forum

seperate your rotation values and clamp each and return them to your rotator or your actor which ever you are using

Use BP Node ‘ClampAngle’

1 Like

Unfortunately, you cannot simply clamp individual euler rotation axes because the axes affect each other

not sure what you mean by you cannot? you split the struct value pins and clamp each axis individually it would actually work no different to clamp angle, its a bunch of floats clamped.

All you are doing is limiting those floats to between the ranges you want

Here is a post doing exactly that:

It’s not that you can’t clamp the individual angles but you will get incorrect rotations

This is a problem with using ‘set rotation’ nodes ( when you break out the pins ).

‘Add local rotation’ is always safe, if you can use it.

Otherwise, you’ll need to calculate the start and end points of what you want to do in terms of rotators ( using ‘combine rotators’ ) and then you can use a node like ‘set … rotation’, as long as you use a rlerp with ‘shortest route’ set.

It’s because the rotation nodes understand about gimbal lock, but if you’re only setting one axis ( which I assume you are here ), there are certain points where it’s not clear to the system what the orientation of other axes are. And then you get this jump.

1 Like