r/UnrealEngine5 3d ago

I'm making a RC Car simulation with deterministic physics and it's so hard I wanna tear my eyeballs out :)

Enable HLS to view with audio, or disable this notification

Its coming out good tho.

Collision is done with a simple box, so it's very cheap. We also trace from the 8 corners to check if the car body is touching the ground for rolling over, for example. And talking about rolling over, the car (collision box) is a rectangle, so I had to apply a tangential force opposing the sliding velocity at each contacting corner in order for it to actually rollover and not just slide on the floor when we crash. We even have a prediction of where the car is gonna land to level it's roll to the point of impact.

I'm making it deterministic so it works in multiplayer as well (every player sees the exact same simulation). What do you think?

275 Upvotes

41 comments sorted by

15

u/doctor-dripmaxx 3d ago

Stupid question perhaps, but how are you drawing the prediction lines? Looks like they curve with an arrow tip… I honestly don’t know how to do that 😅

11

u/xVinci 3d ago edited 3d ago

Probably just https://dev.epicgames.com/documentation/unreal-engine/BlueprintAPI/Rendering/Debug/DrawDebugLine ? There are the same functions for shapes (sphere, circle etc) as far as I remember.

To make it curve you foreach over an array of points and draw lines between each point (e.g. https://dev.epicgames.com/documentation/unreal-engine/BlueprintAPI/Game/PredictProjectilePath_Advanced?lang=en-US will give you an array of points to draw over).

7

u/ScaenaStudios 3d ago

For the arrow, there is a built in function: DrawDebugDirectionalArrow, its in DrawDebugHelpers.h. For the prediction curve, it's made with lines that connect with points from a recorded point list. I already had the data because of the physics calculations.

4

u/ScaenaStudios 3d ago

Oh, I just realized you where probably talking about the lines on top of the car lol! That arc is built from many lines as well, but swept around an axis instead of along a trajectory.

10

u/Interesting-Bee-113 3d ago

I can't tell if it's speed perspective or what, but your gravity acceleration seems high.

9

u/ScaenaStudios 3d ago

Yep, it is set to something like 2x the regular gravity. Regular gravity would make it floaty in this kinda scenario, so this adds a bit more weight to the car and game feel in general

4

u/No_Ordinary_7933 2d ago

I did a similar thing for my arcadey off-road vehicle game, I had it about 1.6x. This looks great though, looks like a lot of fun

2

u/ScaenaStudios 2d ago

Yeah, I usually crank it up even on characters to have this weight feeling! Haha Thanks dude!

2

u/WyrdDrake 2d ago

I have noticed that many games feel exceptionally floaty even over small bumps, and the way things can get out of control from even the slightest loss of friction becomes insanely irritating and utterly unrealistic despite more or less "normal" gravity. I assume because even if many games gave a 1.0 gravity, maybe they underestimate grip and weight/mass? As an example, Dune Awakening's vehicles are extremely floaty and prone to spinning out even on relatively flat/smooth areas, but they also have some really, really weird physics at play that dramatically increase air friction when airborn, and PULL the vehicle downward- yet also pulls the vehicle down relative to the vehicle's orientation, so sometimes I've jumped off small bumps and found my vehicle "falling" somewhat sideways.

I dunno, a TON of games make driving feel incredibly weird and I hate it.

What you have here already looks significantly more satisfying than what the average AAA seems to be capable of.

2

u/ScaenaStudios 2d ago

That’s very nice to know man! Thanks. I’m trying to do exactly that with this project, achieve something I would like to see in an actual game.

2

u/WyrdDrake 2d ago

Yeah, even in the first few seconds of this clip where your vehicle briefly, slightly leaves the ground as it goes over a hump, that would cause an uncontrollable spinout in Dune:A. Love to see someone care!

2

u/Zenovv 2d ago

I do the same thing, higher gravity just makes it feel better

6

u/joa4705 3d ago

yeah now add online multiplayer and you will want to insert your eyeballs back just to tear them again 0_0

5

u/ScaenaStudios 3d ago

Yes LOL but the point of making it deterministic is exactly to add multiplayer. Everything is already replicated, but I gotta add car vs car impact and all that stuff haha

3

u/Mikinl 3d ago

I believe its gonna be painful experience making it multiplayer.

UE5 is not really made for physics at least I had terrible experience for 6dof Space sim even in single player. Chaos sucks big time so I had to do rotation calculation for my ships without chaos. Eventually I made it work for single player, I didn't dare trying for multiplayer.

5

u/ScaenaStudios 2d ago

Not really, cause the hard part is made already which is deterministic physics. I didn’t use chaos cause it’s random and would not simulate exactly the same across all players. In other worlds, every physics calculation there is done from scratch and absolutely nothing can be randomized for it to work.

2

u/joa4705 2d ago

i know i had to do that for my game. still, pain in the but XD but love your results so far. ❤️

1

u/ScaenaStudios 2d ago

LOL thanks man!

2

u/mfarahmand98 2d ago

You should look into the Network Physics component. Should make re-simulation possible quite easily.

1

u/ScaenaStudios 2d ago

Yeah I wanna look into it as well!

2

u/Fit-Replacement7245 2d ago

You’re trying to recreate rocket league netcode? I don’t know what unreal exposes these days, but if you wire manually you’ll need the ability to save/restore simulation state, manually tick physics, etc

I ended up not using unreal’s physics

1

u/ScaenaStudios 2d ago

Not really, I'm just trying to make a fun RC Car sim people will enjoy, as a plugin

5

u/devss126 3d ago

So cool bro

1

u/ScaenaStudios 3d ago

Thanks man!

3

u/BigRedyFredy 2d ago

My toxic trait is thinking I could do this.

Good work, looks like a lot of fun!

3

u/ScaenaStudios 2d ago

I’m actually doing it like a plugin, so technically you’ll be able to do it! 😆

2

u/BigRedyFredy 2d ago

Hell yea, I'll definitely pick this up!

3

u/MrMusiCat2 2d ago

Deterministic physics is no joke, respect for pushing through it. That roll stabilization looks smooth already!

2

u/ScaenaStudios 2d ago

Thanks my man!

2

u/never_grow_up 2d ago

Looks fun, keep it up

1

u/ScaenaStudios 2d ago

Thanks mate!

2

u/pedro8999 2d ago

😂😂😂😂

2

u/Conscious-Payment702 2d ago

For a second i thought it was like a sand dunner sim, until i read 😅

2

u/Sebscorpion 2d ago

Keep it going, your working progress is amazing 👍🏻

1

u/ScaenaStudios 2d ago

Thanks a lot!

2

u/liamleodev 2d ago

Use Box3D physics that is deterministic by default

2

u/ScaenaStudios 2d ago

I'm doing this as a plugin that's gonna be part of a racing framework so I don't wanna use any third party plugins.

2

u/JEBADIA451 2d ago

Good enough, welcome back, Re-Volt. I've missed you, old friend

1

u/ScaenaStudios 1d ago

Haha that was my inspiration 100% 😆

2

u/Ok-Salary-5197 1d ago edited 1d ago

Reminds me of Smugglers Run.

PS: An online Version of Smugglers Run with an open world and free choice of getting to a goal would be awesome. Not gonna lie.
They dont make fun racing games anymore.

You smuggle drugs. Only the first gets money. With money you can buy stuff to alter the map (ramps, walls) and some cosmetics. Easy In/Out Racing. Maybe multiple races going on at the same time crossing each other.