Home Unreal Engine

Blueprint vehicle movement help

Asim7
polycounter lvl 9
Offline / Send Message
Asim7 polycounter lvl 9
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

  • Alex_J
    Offline / Send Message
    Alex_J grand marshal polycounter
    questions like this are best asked on the official unreal forums

    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
  • Asim7
    Offline / Send Message
    Asim7 polycounter lvl 9
    Alex_J said:
    questions like this are best asked on the official unreal forums

    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
    Thanks, yeah I might give it a try on the Unreal forums I didn't even think of that.
    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 :)
  • Alex_J
    Offline / Send Message
    Alex_J grand marshal polycounter
    you can also draw a debug line to visualize vectors. there are  a handful of draw debug... nodes to draw various shapes.

    if the input float is good, next thing to check is that the vector is what you expect
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    For this sort of stuff it really helps to try and separate what happens visually from what the vehicle/character is actually doing . 

    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

Sign In or Register to comment.