News for hackers. Stuff that matters.
Re:Show HN: Simple 2D car physics with JavaScript by dahart on Wednesday January 01, 2020 @12:10PM (#21929003)
I was vehicle physics lead for a couple of games that sold very well, but are not considered racing sims. Happy to answer questions as best I can.

What is missing from Torcs? It looks like a pretty good place to start, it has independent wheel modeling, and suspension, and mass shift of the car (I suspect it can handle mass shift of the driver if that’s what you’re after).

You can probably model frame deformation yourself by building a frame in a physics engine out of flexible parts and/or joints, but I’m skeptical that it’s worth the effort when modeling indoor karts, I’m not sure they flex enough to matter, but it depends on exactly what you’re trying to do.

The car physics my team built was made on top of the Bullet physics engine, so Bullet handled integration and collision dynamics, and we added transmission, braking, suspension, wheels, etc.

It’s definitely worth asking yourself how good you need the simulator to be, and how serious you are about this. It’s a multi-year project to get something “good” and/or better than Torcs. I would tend to agree with their answer to the FAQ question “should I start my own racing sim project?” http://torcs.sourceforge.net/index.php?name=Sections&op=view...

Re:Show HN: Simple 2D car physics with JavaScript by wiz21c on Wednesday January 01, 2020 @05:07PM (#21931068)
That's a very good answer. Torcs is good but somehow the code is not 100% clear to me (I didn't catch the independent wheels simulation for example).

Flexing frames maybe overkill, you seem better placed than me to estimate that.

The FAQ answer address the difficulty of running an OSS project. It doesn't address the difficulty regarding the physics (which, I understand, maybe even more mindbending).

This is a hobby-level project. Nothing serious. I'm more interested in understanding the maths and physics. Having watched hundreds of races (my kid drives), I've seen behaviors which are pretty specific to karts (I guess). For example :

- driver mass shifts do matter (pilots constantly use them)

- karts jump when taking corners too fast and too tight (they usually slide, but when it's too much, they do jump, and decelerate...)

- turning wheels left/right very fast is used to brake during pit stops.

but you're right, I may be out of my league here :-)

Re:Show HN: Simple 2D car physics with JavaScript by dahart on Wednesday January 01, 2020 @08:42PM (#21932267)
By all means, go for it, just do it with eyes open, it’s a lot of work.

The other thing I’d add is that the physics models is only half the battle. The car and track geometry is critical to making an accurate simulation. It’s easy to get wrapped up in the car physics and forget to deal with the angles and bumps and materials and temperature of the road surface.

Cameras are huge too, if you do anything other than a fixed interior cam. A naive follow can behind a car can totally undo all the physics.

Good luck!!

Re:Show HN: Simple 2D car physics with JavaScript by gmueckl on Wednesday January 01, 2020 @01:22PM (#21929542)
The FAQ answer is the kind if condescending tone that I don't like and some developers of long running OSS projects use after a while. I know that these projects are hard and take lots of effort. I've experienced it myself. Warning people that X is more complicated than it may first seem is perfectly OK. But telling them to just stop is wrong. There are valuable lessons to be learned by starting from scratch. Commanding them to help out others instead denies them this experience. Sometimes the journey itself is the goal.
Re:Show HN: Simple 2D car physics with JavaScript by dahart on Wednesday January 01, 2020 @02:07PM (#21929827)
Speaking personally, it would be safe to say my career successes are defined by ignoring warnings like this and doing something from scratch anyway.

So I completely agree, and I guess this FAQ answer is really meant to talk to the casual developer who doesn't know what they're getting into. The person who does know and does it anyway will (and should) ignore stuff this like. I don't think it was meant to be condescending, I took it more as a joking tone but with a real warning that it's a long road, which is true.