Closed emnh closed 9 years ago
I implemented vehicles. Looks quite bad: vehicles get stuck sometimes, they fly too much and don't fall fast enough, plus I disabled rotation because of too much spinning so tanks are not aligned with terrain. Also FPS is low. Perhaps custom RTS physics are needed.
Is there a reason why you need physics support for the tanks at all? It adds quite a bit of overhead. If you're talking hundreds of box-like units I think you'd be better off avoiding Physijs and all generic physics libs and programming the behaviors yourself. Especially if you're only using Physijs for stuff like ground contact.
Under no circumstances would I use the Physijs vehicle stuff in production code (at least until it's had some updates).
Yeah I ended up coding some simple tank movement instead of using Physijs. Performance is much better now :)
I have a small RTS demo.
There are some tanks moving around, just Physijs boxes, not Physijs vehicles yet. Currently they get stuck trying to move into the ground, because I'm not checking that there is contact with ground before applying force in the direction of unit rotation. I use applyCentralImpulse, and struggled a bit to find the right number 1e8 to get tanks moving. Couldn't get applyCentralForce to work, although it sounds more correct to use.
I need a few properties, but generally what I'm looking for is less realism, more RTS-like movement:
I'm thinking maybe I should raycast or somehow trace a path in the terrain and just move at constant speed along it instead of using a physics engine, but I like that the engine gravity takes care of alignment and rotation with terrain. How can I mix and match to get the best of physics while getting more RTS-like movement?
Would it be better to use the Physijs vehicle class? I think tanks can still get stuck and fall over. How does it perform with hundreds of units?
One option is to make the terrain more level to reduce problems with getting stuck, but is more boring..
What are your general thoughts and suggestions?