Attach different weapons to spaceships, modding and space physics

Hi

I’m starting to reprogram my first try of a game (“infinite wars” which was done in jme2) in jme3. This time I also want to do stuff better etc. (have learned a lot in my job as a software developer g).
I posted the first version in this forum, but I post the “game plan” again here:
The idea is a multiplayer space shooter with capturing objectives and an AI for fillers.
In the first version I did a lot from scratch because I didn’t know better at this time. I also completely developed the space physics stuff, which I really do not want to do again (way too complicated g). Since jme3 has this bullet physics stuff, does it make sense to use this in a space shooter? Or does this only work well when there is gravity?
Another thing is attaching weapons to ships. In my game I want the player to buy different weapons for his ship, and also be able to replace them. They of course should look differently. In the first version I used invisible placeholders, but I don’t know if thats the best practice for this. Any advice?
My last question is about modding. How do you enable other developers to mod a game? Of course you can add maps and other models/textures by files, but do you make it possible to add code?

First thing I’ll mention is that you should not make the mistake of having your objects in the world be represented by spatials, physics objects or anything like that. They should be separate information (location, type, speed etc.) in an ES or a database and you should be able to use them and do most of your game logic with only this data representation. The actual visible space with the spatials and physics objects should only be “created” from that data when the user sees it.

Say you know theres a dogfight in sector 4-B of the galaxy, next to planet X or something, you create that physics space and add all the visual objects in that area, then let the player fight. This also gets you rid of the problem of Vector3f and most subsystems being 32bit systems and thus not being able to display value ranges from meters to parsecs, simply because they are too vast. Many “beginners” in this start to put spatials at 100000000,10000000000,101010100000 because they try to represent a whole galaxy in the coordinate system of OpenGL :wink:

This also allows you to quite easily create different views of the whole data, for example displaying the whole galaxy as a “cloud” of jME particles when you zoom out or things like that. Plus you can run your simulation without having to create all these spatials and physics objects and whatnot in memory.

An obvious question with this design is how you can have physics influence the simulation in areas where the player isn’t present. The simple answer is: you don’t. Its completely sufficient if the simulation is about 80% the same as when the player is present. So, for example, you don’t simulate every trader trying to get from planet A to planet B with all asteroids he could bump into and full physics, you simply give him a 60% chance to get hit by an asteroid when he goes that way.

To answer your actual questions as well… :wink: You can use bullet very well for space dogfight physics, I suggest using hull shapes from the final versions of the assembled ships (with guns etc.) for the collision shapes. To assemble ships you can simply make them use the same texture atlas and batch the parts in runtime to improve performance with many objects.

For modding I suggest adding a scripting layer, for example groovy or javascript. Makes it simpler to keep stuff the users don’t need or that would make stuff complicated out of the user-side API. You also don’t need a compiler for running script languages.

1 Like

Thanks for your post, but I think we mean something different with “multiplayer space shooter”. I don’t want to create huge galaxies or something, its more like battlefield or wolfenstein - enemy territory, but in space g. So the maps are smaller than a hugh MMO style game. There is of course some optimization to do with view distance and level of detail, but there won’t be huge distances.
There also seems to be some misunderstanding regarding my second question. I want to mount/attach weapons onto my ships, but that has to be done at runtime. But how do you know where to put the weapon models at your ship models? Placeholders? Or is there another way to handle this? I’m gonna use Blender btw.
Good to know that bullet can be used :slight_smile:
I think I’m gonna try groovy, as thats in the JVM already g.

Well if you still do it this way you can expand the universe… Anyway yeah, simply placing some empty node with userdata on the ship model should do. You can even do that in blender by adding “game properties” (I think), these Strings get imported as jME UserData by the .blend importer. You should still batch your ship models and ake sure the attachments and ship use the same texture atlas.

What do you mean with “batch” your ship models?
And does using a texture atlas have any other advantages other than decreasing loading time and saving disc space? Because I will have multiple ship models, and some of the same weapons can be mounted onto different ships. Do I have to put everything into on texture atlas then?

By batching I mean batching… :slight_smile: Since you are a former jME2 user I suggest looking into the wiki for the transition, two big hints for the move: Never, ever do updateGeometricState() and never ever do getLocalTranslation.set();

Here is a video going a bit more into detail about models, geometry, materials and also batching:

Does batching acutally make sense in a space shooting game? I mean, the ships will be moving, so they can’t be all one static object, can they? It also does not seem to make sense to use a texture atlas for ships AND their weapons, because weapons can be used with different ships. Or does it make sense to make one huge atlas for all ships and all weapons? Isn’t that too much? I guess using an atlas per ship and per weapon is ok, but I don’t see what combining them could do.
The game will also have asteroid fields to fill the empty space g. I guess batching them should be fine because they will not move. But what about collision detection in such a big batched object? Does this still work?

EDIT: Another thing: I won’t be using the SDK because every day at work I’m working with eclipse so I want to use this here aswell. My project will be code heavy, there will not be that many models and textures.
How can I batch my models without the SDK? Does Blender support this somehow? Or do I have to make this manuelly in Blender?

@Wasserleiche said: Does batching acutally make sense in a space shooting game? I mean, the ships will be moving, so they can't be all one static object, can they? It also does not seem to make sense to use a texture atlas for ships AND their weapons, because weapons can be used with different ships. Or does it make sense to make one huge atlas for all ships and all weapons? Isn't that too much? I guess using an atlas per ship and per weapon is ok, but I don't see what combining them could do. The game will also have asteroid fields to fill the empty space *g*. I guess batching them should be fine because they will not move. But what about collision detection in such a big batched object? Does this still work?

EDIT: Another thing: I won’t be using the SDK because every day at work I’m working with eclipse so I want to use this here aswell. My project will be code heavy, there will not be that many models and textures.
How can I batch my models without the SDK? Does Blender support this somehow? Or do I have to make this manuelly in Blender?

http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/BatchNode.html

It may not be worth it for simple ships… especially if the count is low. On desktop, you want to try to keep your object counts in the 1000-2000 range at most. For smartphones/tablets, I guess it’s more like 100-200 max.

re: Eclipse, that is of course up to you… I don’t normally use Netbeans day-to-day either but I use it for JME development because it’s easier. I prefer wrenches to hammers also but I try not to use wrenches to bang nails in. If I were doing DirectX development, I’d probably also use MSVC++. Mostly because I want to develop and not spend all of my time shaving pegs down to fit into different types of holes. YMMV

By batching I mean the ships and the additional parts that can be changed. And the concepts in the video are not just about the SDK. As said, check the wiki for best practices, batching and ho you can do that is mentioned there as well.