I was thinking: "instead of doing the car physics myself I should probably get a physics engine." So, a couple of online searches lead me to consider Avian, XPBD and Rapier. XPBD seems to be dead (because it is the predecessor of Avian? no idea), so that's a no go. So, it is just a matter of choosing in between Avian and Rapier.
After watching a couple of videos and having an AI bot summarize the advantages and disadvantages, I've decided to go for Avian. It's native ECS integration pretty much sold it to me. Time will tell if it is the best choice.
In any case, I gave Avian a try. As soon as I added the Plugin and configured the "car" as a Dynamic Rigid Body, (and got rid of the custom speed code,) the red block was ready to go. It accelerated as expected, and even decelerated as well. However something wasn't right. The "car" wouldn't flip when it fell from the brown platform.
First I thought I was configuring the whole thing wrong. It wasn't that. Then, that maybe gravity wasn't configured properly. It wasn't that. Then that the car had no mass. It wasn't that. So after bashing my head against the keyboard for a while, I found the culprit: the rotation code. It was setting the "car's" rotation angle on every iteration of the code, and overriding any possible changes on any axis. So once I got that patched up, it worked as expected.
I guess now it is time for something more challenging: wheels!
One cannot possibly call that red cube a car without putting some wheels on it. I can't even wrap my head on how to do that right, but the end result should be worth it.
Also, not very related, but I've watched this guy's racing demo, and god, it looks awesome. Not a fan of the camera but I want to reach that sweet level of driving smoothness.
After watching a couple of videos and having an AI bot summarize the advantages and disadvantages, I've decided to go for Avian. It's native ECS integration pretty much sold it to me. Time will tell if it is the best choice.
In any case, I gave Avian a try. As soon as I added the Plugin and configured the "car" as a Dynamic Rigid Body, (and got rid of the custom speed code,) the red block was ready to go. It accelerated as expected, and even decelerated as well. However something wasn't right. The "car" wouldn't flip when it fell from the brown platform.
First I thought I was configuring the whole thing wrong. It wasn't that. Then, that maybe gravity wasn't configured properly. It wasn't that. Then that the car had no mass. It wasn't that. So after bashing my head against the keyboard for a while, I found the culprit: the rotation code. It was setting the "car's" rotation angle on every iteration of the code, and overriding any possible changes on any axis. So once I got that patched up, it worked as expected.
I guess now it is time for something more challenging: wheels!
One cannot possibly call that red cube a car without putting some wheels on it. I can't even wrap my head on how to do that right, but the end result should be worth it.
Also, not very related, but I've watched this guy's racing demo, and god, it looks awesome. Not a fan of the camera but I want to reach that sweet level of driving smoothness.
-CAV

Comments
Post a Comment