So I have a free look camera when I’m in FPS camera view inside of my vehicle, it can free look pitch and yaw in any direction you want (pitch is clamped to -25 - 35) and if you let off the mouse, the camera will stay in that direction and also follow the yaw rotation of the car as well, in doing so I had to un check (Use Pawn Control Rotation) and it all works just fine. Only now if i flip my car over the camera does not follow the roll of the vehicle it spins around my camera on the roll axis and I don’t know how to lock that roll to the vehicles roll and keep everything else the same, if that makes sense.
here is a screenshot of my current Blueprint and Video of what the problem is. I hope I’m wording this all correctly.
One possible solution, the roll in your Make Rotator node is always set to 0, making it always stay the same direction. Try getting the rotation of the car mesh and adding that as the roll value in the Make Rotator. Hope this helps!
Edit: You could also set the control rotation off of Event Tick (when not using control control rotation) and use the same values.
The weird roll may be caused by the position of the center of the car. I’d suggest attaching a scene node to the car’s mesh, and positioning it to where the head will be, and then using the World Rotation Roll of the scene component.
So its not the position of center of car that is the issue when i add roll to that make rotator it somehow rolls the camera but not the controls essentially. when the car is on its side 90 degrees the camera thinks side to side is up and down and up and down are side to side…
I recreated a similar setup, and I definitely see what you mean, it makes the camera turn all crazy. The one thing that fixed it perfectly for me was removing the ‘Set World Rotation’ nodes. Once those were gone, it turned left/right perfectly even when the actor the camera was attached to rolled.
If those are important to the setup you’re going for I can try another solution, but that should fix it.
Would you happen to have a screenshot of your recreation so I can see what you did with all the math in between add local rotation and the old set world rotation? if you that makes sense.
I apologize for the late replies, but yea a bit later today when I get home I can send you the code. The way I went about it was I disabled control rotation, and then used Attach Component to Component to attach the camera to the scene component in the vehicle. Then once its attached I used Add Relative Rotation using the same Make Rotator values for up/down you used in the first image.
Then when moving the mouse left/right even with physics enabled and rolling the car over left/right mouse axis moved it up and down, and also allowed the camera to be rolled upside down.
Would you be able to send the logic you’re using to swap between the player and vehicle?
That’s not a problem at all take your time! I appreciate the help with this problem vey much! and Yes I can show you my logic for entering/exiting the car its simple and temporary, I’ll be making it more dynamic later on once I figure out my camera issues I wanna make an interaction system using blueprint interfaces unlike i have now, which is just basic and simple and not dynamic. I’ll also try what you’ve done with or without the photos but I’d love to see what you’ve done and that makes sense what you changed to get that to work I did not think of that!!
Here’s my current simple logic for entering/exiting vehicle.
Ok so I found a guide on YouTube on how to disable gimbal mode ( Unreal Engine 4 Tutorial: 6DoF Fixing Gimbal Lock its a 6 year old video but it still worked with ue5.4 and in the code I’m gonna share you’ll see nodes having to do with “Quaternions”. It’s mostly for a flying game of some sort but I found some use for it with a camera, how ever I am now facing a different challenge…
So I guess you can say I solved my problem with a little bit of C++ for the new nodes which I can use for an airplane as well. I think that’s gonna do it for me on this matter lol I’m pulling my hair out trying to get the up and down functionality of the first picture of my code but the rotational X and Y lock to the vehicle you see if these videos, but if I add pitch into the factor I get a weird roll. I think being able to look around you on the z(Yaw) axis is good enough for now, I guess.
Alright so this should fix the issues you were having. For this approach make sure when selecting your Spring Arm you set ‘Inherit Pitch/Yaw/Roll’ all to True. Then this approach will rotate the camera with the vehicle in all directions when driving, and when the player turns the camera (can also do a branch if “Free Look” is going to be toggled on/off) the camera will rotate on the pitch/yaw axis like normal, and when you release it will delay then smoothly rotate back towards the center. I’m sure there’s a lot you can do to fix this approach but it worked perfectly for me, even when tipping the car over.
Again I hope these replies weren’t too spread out, but that fixed the weird roll and all other issues I noticed, and hopefully it’s the look you were wanting. You can also remove the gate and most of the code, except the “Add Relative Rotation”, if you don’t want the camera to recenter.
None to worry and thank you for the help I really appreciate it! I’ll give this a go I’m definitely not that great with vector math and still learning blueprinting so I didn’t think to use a lot of what I see in your photo! It’s definitely helping me learn how to control my camera better! thank you!!
I just add your code in the game and reactivated my fps camera and its exactly what I was going for to the teeth! it even pulls the camera forward when you move! Thank you so very much you’re amazing!!
I also changed it so that the turning has no effect on us returning to look forward position but only if we are applying throttle will it look forward and I’m gonna make it look in the opposite direction when we are in reverse! I’m so relieved! haha
For those of you who come to this thread after this last post of mine this is the end result and this thread is RESOLVED
This is what I was trying to achieve thanks to this kind human Chasetopher!
It works so well!! at most I’ll maybe add more smoothing to the camera movements when it rotates us back to 0 and 180 degrees depending on our forward or reverse gears or maybe have it rotate based on velocity, for now its good enough to keep building in other areas!