I’m fairly new to the jmonkey engine but have gone through most of the tutorials here with a success. However I do have a problem now and hopefully someone can help me out with this one. Basically – I know how to load my own scenes, import my own models, create physics, how to move objects (using motion track) etc. But how can I move and object in the scene keeping in mind the physics? So for example, let’s say I’m creating a racing game – how would I go about creating the “enemies cars” that move alongside my own car and that would abide the laws of physics (gravitation, friction etc.)?
I hope you get the idea of what I’m trying to do. Anyone?
MokeyZone has code that lets the AI steer the car towards a point. You could make the car track a spatial on a motion path or something akin to that.
You can have as many phyiscs objects as you like.
Player and NPC cars can be handled exactly the same - just control the player car from the inputs and the NPC car from an AI.
Well it’s not easy. Keep in mind, you wanna use vehicle control for the player controlled vehicle. That way you get suspension and rolling wheels and some other things. If you add a vehicle control to the AI car, however, it’ll be extremely hard to manage. You’d have to keep track of all its variables, velocity, friction slip etc. and add a large amount of logic and restraints to control it. This is extra hard if the car is moving with high speed or on a somewhat rough surface.
I would strongly recommend a custom control for AI vehicles.
The thing is if you do “full physics” you have to compensate fully. Highly skilled engineers work on fly-by-wire systems or try to make robots walk without falling over. Its really not easy. In computer games you have a lot of chances to “cheat” amd make it so that it only looks like “real” physics to the user/player. And this chance is used extensively in AAA games