I am not experienced in programming or blueprint, I know just very basic stuff.
I was following a tutorial for a vehicle, but I wanted to do some extra stuff. Like making the vehicle tilt on the side as it turns. Like in this image, the vehicle tilts on the Y axis not just turning.
The tutorial made the vehicle tilt backwards and forwards during acceleration via the Set Center of Mass on the X axis. Like this
Based on acceleration (W & S on WASD controls) the center of mass changes on X axis by 50.
Now I want to do based on steering (A & D keys) the center of mass changes on Y axis (left and right)
I did it like this.
The tutorial used add torque to make the vehicle turn on the Z axis left and right, i'm then adding the center of mass shift sideways. However! It is only doing it on 1 side, if I turn left mass goes left, if I turn right the mass still goes left
Any ideas or help with this?
Here is the vehicle
Replies
i wont look into the details on this but here is some general information
given an input of some float value like an input axis value, that is going from positive to negative
you can use a map range clamped node to normalize the value
for example, turn a range of -150 to 150 to -1 to 1
from this you can do pretty much whatever you want, whether that is directly lerp the vehicles rotation, or adjust some parameters for the physics sim
it's a little more advanced, but once you are familliar with map range and normalizing values, should look into using curves assets as well
a curve works same way as Map Range node but gives you more control.
if you are a beginner following tutorials, i'd forget the physics sim stuff, it is way too complicated. just set rotation values on the static mesh directly instead, you will get similar look and you will understand what is happening and be able to modify it to your liking
It's just that it seemed so close to working, it does everything I want but the tilting only happens on one side.
I tried connecting it into a print string to see if I was getting only left input but no, left prints 1 and right prints -1, so negative input / opposite / negate. Just like the forward and back.
Thank you for the help though, I'll ask on the unreal forum but otherwise I might ignore this for now and come back once I learn more as I go along
if the input float is good, next thing to check is that the vector is what you expect
Tilting the vehicle actor itself will result in you fighting the physics code. if you tilt the model within the vehicle actor then that problem goes away.
This is basically how a standard third person character works and is probably the best bang for buck option unless you're going for a hardcore physics sim