How limit spring arm pitch during rotation?

I tried clamping the variables, but the blueprint freaks out when I clamp the float variables. Anyone got any Ideas on how to limit the Pitch in this Blueprint.

Hi,

  1. What exactly do you mean by limiting? If you want to limit the total relative rotation, here is your answer;

You should use clamp nodes after adding rotation and before setting rotation node. Take a look at this simple setup for a better understanding;

  1. If you want to limit the rotation rate, then you can divide the ‘Can Turn Rate’ variable or the axis value itself by 2 (or whatever number you like) then plug it into the multiplier node. And if you want to limit the rotation rate to remain in a specific value range, then plug axis value to a clamp node, then plug the clamp into the multiplier.

Hope this help.

Regards,

2 Likes

Thank you, that worked perfect! I have a question for you though? What is the purpose of adding the rotation and then setting it like this? Also Why do we break the rotation up with the break rotator like this? Sorry for the questions im just trying to learn as much as possible.

Because when you use ‘add rotation node’, you have no control over the total rotation. It just receives a delta value to add to the current rotation per execution. So in order to clamp the total rotation, you need to use ‘set relative rotation’ node to control the total rotation. Breaking the rotator, grants you access to each rotation axis value (X, Y and Z rotators). In this case you can clamp rotation over each axis separately.

Thank you for the explanation.

You’r welcome

Hi, im trying to achieve similar effect but I cant get this thing work.

Im trying to add mouse movement to camera and than limit the yaw and pitch to certain degree. Byt when im adding “set relative rotation” node my camera rotate to undesirable place and I cant move camera.

thx for help

Hi,

Because u r doing it wrong. u should use get relative rotation instead of world rotation. getting world and set it as relative doesn’t make sense. You should do your math either in world space or relative space. You should also plug the ‘get relative rotation’ X and Z into the set relative rotation node. at the moment u are hard coding roll and yaw rotation values to 0. One more thing, you probably should work with spring arm rather than camera itself unless it’s an fp camera otherwise you won’t get correct results based on my exp.

regards.

Thanks for replay at such a short notice.

Yours solution is almost perfect but it works only with Y (Pitch) when im trying to clamp Z my camera is turning 45 degree however clamping is working on both values Y and Z. When im limiting only Y and pluging Z straight from rotator to relative rotation everything is perfect so the problem is somewhere in Z space.

Its FP camera but im changing it using “view target with blend” so I can try attach it to spring arm if you thing that would help.

not sure if i understood u correctly; first use print node connected to event tick to print out yaw values per frame. then check on what range u get the proper result (it may not be between -10 and 10 necessarily). after finding your proper range for yaw input, use that range. one thing to note is that the relative rotation is relative to the parent component and if the parent is root, it will give you world rotation.

Ha it works! Thanks man, since you are an expert in limiting rotation I have one more question.

This time i would like to limit rotation in my character blueprint. I was trying to use “view pitch max/min” function and it kind of works. It is limiting my ability to look around but again my camera jumps to a random degree.

Im trying to add this limit to my character ability to lean left or right.

Hi, i had set a graph that similar to LordZedd’s graph, but my character’s view just do nothing and values from “print string” are correct. So are there any setting i need to set?

by the way, what i want to do,is to limit yaw but not in world rotation, can you give me some suggestion? Thank you.

those are my blueprint in character class event graph and some settings:

262617-捕获3.png

and those are animation blueprint event graph:

Well, I crest a new graph and it work, but still in world rotation, character can only face in one direction, I would like to make limited yaw in every direction.

Your had said “the relative rotation is relative to the parent component and if the parent is root, it will give you world rotation.” Am I need to edit in C++?

would you give me some suggestion? Thanks a lot.

character is one component, camera is another. First you must know what exactly u are gonna achieve. if ‘use control rotation’ check box is checked, your camera automatically read from mouse input (if mouse input is already set in project settings). By default it is checked. but for some rare situation you may want to uncheck it and manually set camera movement based on mouse X/Y input nodes. you don’t need to go through c++ for doing what you need. The thing is first you must have a solid understanding of rotations and how they are implemented inside unreal engine. I have answered a similar question a while ago. check it it may be helpful.

Thank you so much, about what actually want to do, i am no sure i can explain it clearly by words, so i make a video, hope that can help to explain what i want.

and the similar question you just post, i will have a look right now, also waiting your reply, thanks again.

Well, this video can show what i actually want to explain more than the first video i just post. Hope this can be help.

Here is your answer with some delay. I was just within "one month don’t answer any question of the year of my life !! "

Go to character BP and follow my steps:

1 - Follow this graph which controls the mouse input values. I noticed a strange behavior when unchecked all inherit control rotation check boxes from camera boom. I noticed ‘get world rotation’ gives nonsense values while ‘get relative rotation’ gives me world rotation values !! That’s why you may get confused a little when see my graph. That is a bug i guess.

2 - select your camera boom and set the settings below:

265110-capture2.png

3 - erase everything within movement input section of the character BP graph and replace it with mine:

4 - select ‘class default’ tab from the toolbar above and follow this picture:

265132-capture4.png

Now you are all set. But a problem will rise when trying to limit camera boom rotation values. Which is, when your character tries to move backward (toward camera) he will enter an infinite loop. And that’s totally understandable. I leave this problem for you to solve. But to give you a direction where to look for it, you may need to make some changes in the third picture.

Regards,