Help with theory.. Deciding Drag to Apply

This is a general Unity related question, but not tied directly into any of the courses. It’s sortof a tangent off of Project Boost that I’m working on.

For this project, I need to simulate wind resistance based on the shape of an object. It doesn’t need to be accurate to realistic physics models, just evenly applied in the game so there’s a benefit to aerodynamic shapes vs cubes. I’m thinking of ways to approximate it via code. I know I can apply drag via rigidbody.drag. I’m just trying to determine how I should come up with what number to apply.

I don’t really need to calculate anything other than the object’s forward direction for what I’m doing, so maybe I somehow find a cross section that is exposed to the wind in that direction. (Not certain the best way to go about this. Maybe using information from a collider I provide to test it?)

Alternatively I could fire a whole bunch of rays at the front of the object from some fixed position ahead of it. Then if the distances before the rays hit something was close to the same, I could assume it was blocky, if the distances were far apart then assume it was slanted, and probably more aerodynamic?

I’m kinda leaning towards the ray solution unless anyone has a better idea. Thanks for any input you might have.

If there’s already an easy way to determine drag of an object built in to Unity somewhere, that would be great too.

Hi Zafaron,

Have you already looked for tutorials on Youtube? I found these:

Part 1:

Part 2:

Please feel free to ask for advice from our helpful community of students in the forum or over on our Discord chat server.

Good luck :slight_smile:

I didn’t even think to look for wind zones. That makes sense though. Thanks Nina.

I checked out those videos and while helpful for adding general wind they don’t work for what I’m doing. I’m working on a racing game where the players have some customization options on their vehicle. What I would like to do is make vehicles that look like a cube have more wind resistance than ones that look like a wedge, for example.

It may be easier to just assign all of the pieces they can choose a drag/wind resistance value, rather than trying to calculate it on the fly. I think I will do it that way and save myself the headache.

If you design the cars yourself, you can simply multiply their speed by a value based on their shape, e.g. 1 for an aerodynamic shape, 0.5 for a block, etc. Instead of using premade windzones and physics, you could define zones and do the maths based on the “forward” axis of the car and the presumed direction of the imaginary wind.

There is no need to involve “real” physics.

Yeah, this is pretty much what I settled on. Doesn’t need to be ultra realistic for my purposes. Thanks again for the input.

I’ve just noticed that my sentence was not complete. I edited my previous answer accordingly. :confused:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms