Is there a more efficient wat to limit a component's rotation?

Hey everyone, I’ve set up these little nodes to only accept a positive value of the mouse X input after the component hits the -40degrees mark on it’s Z axis. Basically I’ve tried to limit my component Z rotation to -40.


What’s problematic about this is that if the sensitivity is set little too high, the code only fires once it’s past the -40degree mark, sometimes at -50 and sometimes even at -70.
It’d be great if you could suggest a better approach other than this and the one that involves setting the camera manager’s max rotation values. Thanks!

This is kinda like the camera control I have on my player. I just use the mouse axis to move between two values and have a clamp node.

Positive adds ( up to a point ), and negative subtracts ( to a point ).

Does that make sense? ( I can lookup the code… ).

To be honest, I’m not sure if it’s my English that had failed me or my lack of solid Unreal knowledge.
I’d be grateful if you could post the nodes whenever you can :slight_smile:

Gimme 5…

1 Like

So, this is my camera look up/down code. I don’t want it to go past 90 in either direction. I’m assuming it’s the same for your turret, but in Z:

2 Likes

It works wonderfully! I also wanna ask you about the GetWorldDeltaSecs node, what’s exactly it’s role in this equation? I’ve heard that it synchronizes the physics engine with the renderer but can you please provide more insight?

Nothing to do with physics.

I’m sure you’re aware, you can change the frame rate of your game with t.maxfps, I think the command is.

Try removing the world delta seconds and setting the fps down to 20. That’s what your game will play like on a heavily loaded machine. You discover that everything moves really slowly. Which it shouldn’t :wink:

The GWDS compensates for that.

As the frame time gets longer, you will end up moving further, with this equation.

1 Like

I only use the Project Settings to set the FPS but I understand what you mean, it basically keeps the game mechanics working the exact same way regardless of framerate. Understood!
Thank you :slight_smile:

1 Like

I recommend trying the console command, it’s quite illuminating…

1 Like

Ok, this totally works for me! Problem though: when I do a second one for the x-axis, the two start competing with each other and it locks up! No movement! If I disconnect one, the other works. Happens this way both ways. What’s the deal?

You need to limit them at the same time

The name of these nodes

image

will vary depending on what you put in the project settings

1 Like