Confused by my own bp.. ship roll

Hello i am trying to figure out how to reset the roll of my ship when the input axis is 0 … But i am having a major headache … I have created a variable called input right and this is set by the axis value … Now i want to say (IF INPUT RIGHT IS >OR< THAN 0. SET WORLD ROTATION TO O ) However i cannot get this to work … Could somebody please take a look at my bp and point out what i should be doing ? When i use the above method the ship rotates far beyond 90 degrees and is all messed up

Doesn’t look like you’ve included any specific nodes to set the Roll Rotation there…
But rather than struggle this way, why not use an existing template and tweak it???

I have been tempted to use a template but i am a slow learner and forcing myself to find solutions is the only way i manage to learn .I find it very hard to deconstruct others work and make it work for myself .Also that bp i shown is how my current setup works and does not realy show my attempt to find a solution .It was me saying this is what i have does anybody have any ideas on how to implement “this” etc etc the following bluprint is my whole setup of my ship character as of now

Interesting to see how devs learn differently. To me its much faster deconstructing something that works.
By you doing this all yourself (trial and error), I’d be worried about running into things like Gimbal Lock etc.
I see now you have a Roll node but I’ve never used that one and no idea how it behaves (AH doesn’t help).
The tooltip mentions multiplying this by the PC’s InputRollScaleValue, yet the target is Pawn, yikes, WTF?
So still petitioning you to returning to use something that’s proven to work, other than that its guesswork… :slight_smile:…_Pawn_Tutorial

Yh i guess your right . I have not gotten far into my dev on this project anyway so i guess its best to change my approach now rather than later .Which is a shame because i love how my current setup feels .:frowning: .Apart from the issue of not rolling back into its start position it works prefectly well …Oh well you live and learn i guess thank you

I wouldn’t give up what you’ve got working so fast… That’s not what I’m saying…
What I would do is borrow from the links above to correct-the-roll back to ‘flat’.
So use the other nodes above for that (for now), until you progress further etc.

Ok so i have been trying for hours and have had a good look at .At least 5 projects and i am still stuck.My project is now stripped back to the very very basics Could some more people see if you can offer some more advice on this please as i am ready to abandon yet another project

Can you tell exactly what are you trying to achieve ?

Hi and yes of course my blueprint above is supposed to control my ships forward motion and the body roll. as well as the left right movement.Now most of that works fine …However i need my ships roll to be leveled out when the input axis =0 Currently my ships rotation is not reset to 0 when the left analogue stick is released .hence it keeps moving in that direction and my roll is not reset …Hope that makes sense …I will be the first to admit im not a bright guy so please bare with me…PS thank you for any help in advance

You need to interpolate back to zero (flat) smoothly, probably in a loop run off tick or use something like a physics constraint to ‘right’ the ship mesh automatically. Epic’s free hover ship exhibits this behaviour so you could just look at that. Can’t help further as I’m not familiar with the nodes you use… They seem to work a bit differently to the more direct Add-World-Rotation / Set-Physics-Angular-Velocity etc…

Here is a way to do what are you looking for.
To avoid issues, it’s better to work in relative space so look at the hierarchy ( ship mesh is attached to a collision sphere)

Hi i implemented this blueprint into my project and the ship does not roll. It moves very slowly left and right but with no roll …I appreciate your help guys And i am very sorry that i am so incompetent .My mind is dragging me towards other projects which is what always happens when i hit a roadblock .Hence the reason i do not have any completed projects to show . Be honest guys should i take up knitting or something lol . hahah Can you tell i am feeling defeated?

Pity! The first part of Mhousse1247’s code looks like its responsible for smoothly correcting the Roll back to zero.
Is your mesh / mesh hierarchy connected correctly, in this first ‘Sequence Branch’… Sounds like maybe its not???

Hmm maybe i will take a look

is this wrong?

Show everything. The BP too!

Hey sorry and ok

Look at the setup I posted last day , I’ve already mentioned " ship mesh is attached to a collision sphere" and I pointed it with the arrow.

With your setup Ship mesh is the root component so it will not work !

Hi and im sorry i can tell your getting annoyed with me :slight_smile: Lol i did notice the collision sphere thing you pointed out but was not quite sure what you meant . As i said before i am a bit of a dunce .However it is now working flawlessly …I would however love to know WHY it works …If anyone has the time i would love a brief explanation of what the new blueprint is actually doing . I am very grateful to you guys for your help .

I’ll have a go and maybe @Mhousse1247 will correct things later… :slight_smile: BTW: Disclaimer - I’ve never used Floating-Pawn-Component / Add-Movement-Input / Add-Controller-Input before, so there may be some guesswork here…

The new BP is split into 2 branches (Sequence node). The top or first branch corrects the roll… I’d suggested doing this before in tick, but InputAxis has an auto-tick. The code gets the rotation of the ship and breaks off the roll (Break Rotator). This is then passed to FInterpTo, which is a common node for interpolating between two points to generate a smooth transition (to flatten out the roll of the ship). In short, if you don’t have this, the return to a flat roll might seem jumpy or jerky etc. Delta-secs helps as well to compensate for varying frame-rates etc. We need to rebuild the rotation (Make Rotator) in order to pass it to Set-Relative-Rotation, which actually does the movement (everything else is just calc-work otherwise)…

The second branch… I believe it does what you had before only better as it seems to scale the degree of roll based on the value of ‘input axis’… First, the code checks if Player Input is greater than zero, as you don’t want to flip the ship mesh to the side if there’s no input etc. BTW: I was curious if these two key branches would conflict / fight each other. But the fact that you confirmed it works perfectly, means that a separate check in the first branch for Input = Zero isn’t necessary. That’s the difference between reading code and deconstructing something that works…

Anyway, normally you get the Forward-Vector to move the ship forward in the X direction (x is forward in unreal). But here we need to change the roll so the code gets the side-to-side or the Right Vector (Y) and captures the Sign too. I believe its done this way to encapsulate the code into just a single-section (but you could also have separate Left-flip / Right-flip code branches based on whether the InputAxis is leaning left or right). The last part is Clamping, a common way to restrict invalid values being supplied to a movement node. You can imagine on a car, you wouldn’t want the steering wheel to be able to turn the wheel so far it gets stuck or damages the chassis etc. So I assume that’s why its here too, to stop the ship mesh flipping over on itself, if the player input is too extreme etc.

Note, I haven’t dealt with the use of ‘Relative’ at all. In general you use relative when you want co-ordinates or rotation of a mesh relative to something its attached to etc. Might be easier to think in character terms. Imagine in-game a player is told to put their hands up by a cop. If you had to animate that you could describe the movement in absolute World co-ordinate / rotation terms. But you could also describe it relative to the character’s body the arms are attached-to, which is more useful because then whether the player is standing or lying down the info is the same. That’s how I visualize it anyway. Note, in my own ships movement code I only use ever use World, so Mhousse1247 will have to advise why Relative is essential here…

The Event tick at the top I assume you’re fine with… But if not it looks like its the code that propels the ship forward continuously - no brakes, infinite-runner type… The key node is AddActorLocalOffset which solely takes a speed var (again x is forward in unreal)… I’m assuming there’s no need to do more calc-work like getting a forward-vector here because the code works in local or relative terms once again…