F-Zero style Vehicle physics

Hi there! I’m trying to make a F-Zero & Distance style hybrid game, i’m stuck at the vehicle physics for now, i placed a placeholder track and a placeholder vehicle which is a simple box for now on. I watched a few tutorials about hover cars but that’s not the result i want, so i tried to make my own, i’m tracing a line from the vehicle to the ground checking if there is a ground, and if there is, teleport the vehicle to the ground + 100 on the Z position, also getting the normals from the ground setting the rotation of the box, well, it kinda works as i want it to work? But it’s very glitchy, the vehicle moves on it’s own trying to get to the top of the road which is weird… I was also trying to make a capsule collider but i didn’t get the proper result. The vehicle should stay on the ground of the road, gravity should be only enabled if i’m off the road, the vehicle should just be stuck hover on the road like it’s glued but i should have full controll over the vehicle. Any suggestions i could try?

Here’s a video on how glitchy it is now: - YouTube

The whole vehicle blueprint: Vehicle Physics posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4

I hope you can help me a little.
Best regards!

I do believe what is happening is, as the vehicle goes off the track it begins to rotate, which causes the line trace to turn back towards the track… When it makes a connection, it resets the vehicle to the point above where it made the contact. (part of your code that sets the rotation to the track)
I thought of several ways to check/compensate for it.

  1. Try it with something like a “dead zone” on edges. Get it so it only works if the ray trace hits the track official. Then put some mesh boundary that wont trigger the effect but will block the trace.
    (might work it into the game as something that drops your speed and reduces the value of your lift the longer you are on it?)

  2. set the ray to always point “down”. Not in relation to the vehicle but world.

  3. Or Keeping the vehicle’s rotation…

  4. An if statement that doesnt correct the vehicle if it has gone past a certain point or, if ray is hitting a “dead zone” at the end.

Hi! Thanks for the quick respond! I checked your second way and it seems to work fine! It was the rotations problem with the line trace. I point the ray always down and so it rotates the vehicle without rotating the ray, now i’ll do some lerping to smooth it a little and so i think i’m happy :smiley: BUT so this will only work on roads which are on the ground, so wall or roof driving and loops will not work with that method, should i try to make more linetraces on the front of the vehicle and top so it will check if there is road in front of the player and above?

oh…gravity play is beyond me…

I had wondered seeing this how complex you would get the float…like in scifi these types vehicles have multiple thrusts/repulsers.

would it be possible to set up each vehicle to have it’s own number/values so they behave different. Then have the boost not teleport but move it giving a larger push when it is closer and smaller when it is higher…so there would be a bob and shift as you went over things. Getting it going too much could cause a wreck?

What about working out something where the track returns a rotation value to the ray cast?

Set the cast to come from a component

Have a variable for an object.
If raycast hits something store it to that variable

Then on event if ray cast is hitting an object have it update it’s rotation to match.

I do see the problem of making goo looking tracks here though. You would design sections you can put together (modular) and have them all aligned in same rotation/axis as that component. when you placed them in your level and rotated them, that would be the rotation applied to that component.
but this leaves you with very blocky tracks. Since they would need to be flat enough that that rotation worked for the whole distance of that section.

Alright, thank you for helping me out ^^ It works like i wanted it to work :slight_smile: It’s still not perfect and big buggy and glitchy but i will fix it somehow ^^ (At least i will try). Best regards!

I will include a screenshot on how my game looks like :smiley:

wow nice jump from a flying cube!

is that a loop i see? what did you end up using?

Oh, that’s no loop, just a curved road using splines. I’ve decide to use no forces for the movement of the vehicle, i move the vehicle using changes in the vector position every tick and some lerping in the acceleration to make it look like it’s accelerating by force, i’m using no forces because i have more control over the vehicle when on track so i can change direction rapidly like a futuristic magnetic hover car would do. Overall the whole movement is based on position change calculation and lerping, it looks great when on the road to be honest, but if i go outside the road it’s like i would still drive on a road without falling, and i can fly in the void like crazy(Which looks cool, but taht’s not what i want) :smiley: Will need to check if i’m on the road, if not, disable the movement and let the engines physics make its work done i guess :slight_smile: Or maybe change to physics acceleration because the motion is more natural, i don’t know.

I would presume a branch would check if your cast to the track is hitting the track.

Be interesting to combine the “thrust” of the vehicle to the tick (Delta time so it’s smooth across frame rates) to reduce the effect every moment you’re off the trathethat way you could have “short cuts” at a risk, areas where you go through futuristic setting, and if you go off the track you float lower and lower moving slower and slower

Hi there, I’m a beginner unreal developer and currently trying to figure out the same type of physics for a anti-grav racing game. I was wondering if you’d be willing to share any solutions you’ve come across so I might cross reference and see if there’s anything that might help me figure this out. I’ve come across a few sources for ideas and tried to merge them into a solution, one including a way to remove gimbal lock for full range of 6DoF using the unreal flying template.

Like you I’m tracing a line from the bottom of my craft, getting the hit impact normal and using that to try and orient the vehicle to the surface of a mesh (or road). Any feedback would be greatly appreciated.

Thanks.

Hi! Did you find a solution for this? I’m having the gimbal lock problem when the vehicle rotates more then 90 degress in the Y axis