A problem with Pawn Rotation/Static Mesh by the Camera!!

Hi! I have a problem a Static Mesh rotation by the Camera. When I look down and try to lean in any direction, it will move weirdly.

On Event Tick.
~ Rotation by the Camera

On Input Axis.
~ Lean Structure

What can I do?

I think the problem comes from some angle rapidly changing value from 0 to 360.

Can you print the Target rotator from the camera on screen and check if there are sudden jumps in value?

If this is the problem:
Try using directly the camera rotation instead of getting the forward vector and making rotator out of it.

If it does not work:
Try creating the rotator with more parameters because 1 axis does not give you enough data. (Make Rotation From Axes might work better)

1 Like

Thanks for the answer!

Both print the same (Camera->GetForwardVec->MakeRotFromX or GetWorldRotation)

I don’t know exactly how to use “Make Rotation From Axes” or what exactly to connect to.

I think that is the problem although I can’t really read it with that compression

The values outlined in green are positive and the values outlined in red are negative. While this would not itself be a problem if the difference was from -5 to +5 for example, some of these swings are from -178 to +127 for a single tick.

I am not sure what you are tying to achieve here but I think you should define your desired rotator better. I can see that you have lean forward/back, left/right but I assume this is in relation of the actor. Can you explain how the camera should play into this?

1 Like

So the camera will rotate the character in the forward direction of the camera, but there is a problem when I look down and try to lean. I just don’t want it to behave like that!

Can you try this macro for taking the camera forward vector?


It should avoid the problem when looking straight down but I can’t test it quickly on my side.

1 Like


The same result with Normalize! :((

:frowning:
OMG! This is what happens when not testing things… I am deeply sorry.
I’ve messed up the inputs of the Lerp node.

A should be the Up vector and B should be the Forward vector.

You can also use VectorLengthXYSquared instead:

Sorry again.

Edit: It wont work again though - I’ve decided to test it more.

Can you check your character settings for me please.
Namely:

  • Make sure Orient Rotation to Movement is false if you are setting it directly;
  • Try removing your rotation logic and setting Use Controller Desired Rotation to True;

OMG! This is what happens when not testing things… I am deeply sorry.
I’ve messed up the inputs of the Lerp node.

No problem, thanks a lot for trying to help me!

Can you check your character settings for me please.
Namely:

  • Make sure Orient Rotation to Movement is false if you are setting it directly;
  • Try removing your rotation logic and setting Use Controller Desired Rotation to True;

I’m using a pawn actor, not a character

You can also use VectorLengthXYSquared instead:

Result:

Pawns also have UseControllerRotationYaw in their class defaults. Try using that instead of manual rotation.

Edit:
I also created a simple pawn with only this code:


And these settings:

…and I somehow avoid that problem.

1 Like

Yes, but it works weird and I don’t have the delay I get with an RInterp To.
Anyway, thank you very much for trying to help me. In time I will find a solution for this.

Ok, I found the solution. It was right under my nose!

Instead forward vector I put up vector!

I’ve added this code and I got the smooth turning and still no bug:


(Of course I disabled the pawn automatic rotation)

1 Like

That’s what I was trying to do with the Lerp however I wanted to get the up vector when the forward vector is not useful anymore (when its length on the XY plane is small)

You will have problems with your solution when you start looking up. (and the up vector starts pointing back)

1 Like

This works well!! Thank you very much!

That’s what I was trying to do with the Lerp however I wanted to get the up vector when the forward vector is not useful anymore (when its length on the XY plane is small)

You will have problems with your solution when you start looking up. (and the up vector starts pointing back)

That is correct. When I look from the bottom up, it will behave strangely!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.