0

I'm working on a short Unreal Engine 4.9 blueprint for a friend, but I am not familiar with the unreal engine at all, and I'm about to pull my hair out. I've been searching online for about 2 hours, and I can't get it.

What I'm trying to do is get the roll of a object, derived from the pawn class, and lock it in between two angles. In pseudocode, do this:

if MyObect.Roll < -50,
    MyObject.Roll = -50;
if MyObect.Roll > 50,
    MyObject.Roll = 50;

Any sort of help or pointing in the right direction would be a huge help. I've seen some post using a player camera manager, and no luck from that thus far. Thanks in advance.

Hoopla70
  • 111
  • 9

1 Answers1

1

First thing to do in such a situation is print your values, e.g. using UE_LOG. You'll notice that your values are often between 0 and 360 instead of what you might expect yourself (-180 to 180).

So, you'll need to 'normalize' your angles first, to get them to be between -180 and 180. That way you can use the code you posted above :)

if (MyObject.Roll < -180.0f) MyObject.Roll += 360.0f;
else if (MyObject.Roll > 180.0f) MyObject.Roll -= 360.0f;

Hope that helps!

Bas in het Veld
  • 1,271
  • 10
  • 17
  • Not the whole problem I was having, but I'm certain this will be the next issue, and you were the only person to try to answer, so I really do appreciate it, thank you :) – Hoopla70 Oct 02 '16 at 17:46
  • Feel free to update your question, because it's not clear to me what's going wrong in your current solution! – Bas in het Veld Oct 03 '16 at 00:24