Download

Igonre X(roll) in SetWorldRotation.

Hi guys got a problem with Set World Rotation, need some help for the solution.

As you can see in the video I’ve made some top down shooter using WASD to move the Vehicle while at the same time the Turret on its top will face mouse pointer.
To make things a bit dramatic I’v build a blueprint to roll the Vehicle a bit left or Right as it turns. All looks just fine until the vehicle turns… When the Vehicle start rolling to Left or right, The turret does not
follow it parent (in this case the vehicle). It just maintain its own roll axis. I want it to stay and roll with the parent while also keep facing to mouse pointer as much as possible at the same time.

I’ think this happens because I use SetWorldRotation to make turret face mouse pointer. Like the BP attachment, I use FindLookAtRotation and only use Yaw axis to rotate the turret. The thing is, as I set the Yaw axis from FindLookAtRotation output, there is no input for Roll and Pitch Axis, there for SetWorldRotation set it both to 0, instead keeping its own current rotation it set its roll axis to 0.0 . So how do I make SetWorldRotation Roll axis to Null or something so it will maintain it own current roll axis?

There’s more than one solution here. You could try plugging vehicle’s roll into turret’s roll for example, that *might *work.

On the other hand, I like it the way it is, the turret has its own vertical stabilisation/target tracking, as seen in this classic:
https://youtu.be/gCW-2_qPlQw?t=6

Otherwise, during banking, you’ll end up firing up up and away…

Perhaps the hovercraft’s roll is a wee bit too dramatic and causes a bit of clipping. Purely personal opinion, though.

edit: ignore that, I see you’ve already accounted for the pitch…

Unless I’m misunderstanding, couldn’t you just ‘getRotation’ of the turret and then plug the X and Y output nodes into the inputs on ‘setWorldRotation’?

Hi @r2art,

I would try 2 different things to see which works best:

Try setting the turret roll to the hovercraft roll

Or

Instead of setting the world rotation, set the relative rotation and leave roll at 0.

Setting the Roll to world rotation 0 basically cancels any roll it can inherit from its parent

Hope this helps!

I will try to set roll to hovercraft…If I found out how that is :D… sorry I’m still new with this thing.

SetRelativeRotation doesn’t work, I have try it… the turret indeed follow the Hovercraft roll but when the hovercraft is turning (change direction) The turret no longer use it own X axis as Forward, the turret forward change along with the direction of Hovercraft or maybe FindLookAtRotation is using parent or root Forward direction instead the Turret local Axis, I’m not really sure…

Hi @r2art,

Its very easy. Here’s what you do:

Drag Hovercraft from the left panel into the blueprint graph to get a reference.
From there, drag the pin and type “Get World Rotation”
Then right click on the Purple Pin and click on “Split Struct”
Drag the Roll and connect it to the Turret roll

That should do it :slight_smile:

Sadly… is not working also -___- its working at certain direction, but when the hovercraft moving to the opposite direction the turret still roll to the original direction.

I have this idea how to work around this problem but I don’t know the function node to do this in Blueprint (or even if its possible or not)
What I need to do is make and Empty Object (or non-renderable object) at the top of the Turret then link it to Hovercraft as child for hovercraft. So it follow the Hovercraft every transform. (like what the turret suppose to do -___-) After that I use another LookAtRotation using Turret’s Up axis to find the Empty Object while simultaneously using its Forward axis to find mouse cursor.

I’ve ask this method to my friend (a unity programmer). He said is possible using Quaternion…something in unity. (he explain this to me in programmer way which then I’ve failed to follow after three words came out from his mouth :confused:)

So… is it possible to do this in BP? because I don’t even know how to use 2 axis at the same time or even use Roll axis for FindLookRotation input.

Hi @r2art,

Thats weird,

Can you post a video of the issue or a few pics of your new setup?

As far as I know, UE4 converts Pitch, Yaw, Roll into Quaternions internally, so its no different than unity.

Another thing you might want to try is using “Add Local Offset”

When Hovercraft moving up seems fine but when moving down the turret roll like Hovercraft moving up

this is the Bp to roll the hovercraft while turning and roll back to 0 as the turning finish.

this is Bp to rotate DefaultPawn to face WASD input direction or Left Thumbstick. I’m using DefaultPawn so Floating pawn movement build in already provide me with movement direction.

This BP is to set Var integer as the DefaultPown rotate to input direction, -1 for left turn, 0 for straight, 1 for right turn, then the variable is sent to Hovercraft rolling part of BP

After you told me to get hovercraft rotation for turret roll.

I get the feeling that BP I build to Roll hovercraft while turning is so…conventional or primitive :smiley: because these are the Function node I know how to use right now.
If you have a suggestion to build BP more effectively I would be grateful.

And sorry for the late feedback, kinda busy this weekend helping my cousin getting married.

Hi @r2art,

Sorry, been busy myself lately. But just looking at your Blueprints, you are moving the hovercraft using relative rotation but the turret using world rotation. Use relative rotation for the turret as well. I think that may fix your issue.