Negating Linear Velocity Along an Axis

I am creating a blueprint for a sort of “Alternative Friction” which should allow for assigning different friction values to different axis. To test this I have created the blueprint shown in the image. It simply takes the current X velocity of the physics parent and if it’s within a range of -FrictionValue to +FrictionValue it sets the velocity in that direction to zero. The issue I am running into is that nothing seems to happen when it’s run. The function is being called every frame as part of the tick event.

Other information:

  • Target Instance is referring to the chassis of the vehicle. I have tested
    adding velocity to it using the same
    reference the attached BP image uses
    so that shouldn’t be an issue.

  • Target Velocity is really just a “Get Velocity (Actor)” node that is
    being done outside of the function
    for organization purposes.

  • I currently have both Friction values set to the maximum values of a
    float but it hasn’t changed the
    results.

  • The friction values of the PhysicsMaterials are all set to 0.0
    so that the results will be extremely
    clear. The vehicle simply slides
    infinitely in any direction no matter
    what direction it’s facing.

  • I have tried using “Set All Physics Linear Velocity” but it had the same
    results.

If I’m going in the completely wrong direction with this solution and there’s a better way to have specific changeable friction values for each axis then I would very much appreciate the input. As you might’ve guessed by the value names this is being used for a “Drifting” system where if the X Velocity gets high enough the friction lowers to simulate losing traction (the IsDrifting Bool). It’s far from realistic but so is the project it’ll be used for.

Fixed it, issue was due to Velocity being a world vector instead of a local one. By adding an “Inverse Transform Direction” node to the start so that I can work with it’s velocity relative to the object then adding a “Transform Direction” node to make the velocity values valid for “Set Physics Linear Velocity” it will all work out.

Just remember to be careful when applying this. If say, the vehicle tips and the side is facing the ground it won’t fall, not sure how to go about that, maybe add some sort of “As long as the bottom of the wheel/tread/whatever” is touching the ground apply this if not don’t.