I am developing a true first person character and need to clamp the camera rotation. I want to prevent the head from rotating 360 degrees relative to the body.
I have an implementation that worked with the old camera system (second image), but I am struggling to replicate it in new gameplay camera system. How do I set these values in Blueprints? (first image)
Hi @Trudedro
Could you describe your problem in more detail? I don’t quite understand what you mean. Would you like to limit the X rotation of the camera in the blueprint?
Kind regards
your description is a little hard to follow: a human can turn their head relative to their body, they can typically go between [-80,80] if you want a different limiter then that is up to you on “realism vs video game”
there is a couple different ways you can accomplish this depending on how specific you want it to be, but you will probably end up with a combination of clamping the InputAction and clamping in the IA_Look.
your code is actually going to be very similar to the previous.
because you have already bound the InputAction AI_Look with the MappingContext In Blueprints your nearly there (C++ gets a few extra steps but I will continue with Blueprints only)
the bottom of the “Input Mapping Context” section of the doc showing how to register the MappingContext to the controller (if we are working inside the controller the node being called is different)
now actually limiting the Yaw (rotation about Z) :
the clamp inside of the MappingContext is referring to the output range for that component of the vector that will be handed to the ‘IA_Look Event’ as a result of the multiplier
because a controller joystick is a vector2<float> where either axis could be anywhere [-1,1] we often apply a multiplier to it to get more meaningful values
similar for a mouse which returns a delta of the motion on the XY plane we often don’t multiply that to allow for finer correction particularly at more precise games
so if you clamped the IA_Look to say [0,0] on the X that means that no matter how much the player moves the joystick or mouse in the X direction the IA_Look will always receive Zero for that component of the vector. you can still clamp it to prevent overshoot with doing the math in the IA_Look Event
on the blueprint graph for your character or controller right-click and search “IA” if you have been consistent with the naming (preceding your InputActions with “IA_”) then it will show all the InputActions that you have created, even those not a part of the current MappingContext.
the value included will be the vector2 after the multipliers have been applied. then you can split the pin (right click “split struct”) the Y value will be the up down, and the X value will be your Yaw rotation. After that you can just use the logic you had previous.