jpaver / opengametools

A set of open c++ game development tools that are lightweight, easy-to-integrate and free to use. Currently hosting a magicavoxel .vox full scene loader.
MIT License
373 stars 35 forks source link

Objects Ids #4

Closed kariem2k closed 3 years ago

kariem2k commented 3 years ago

Thank you very much for this library is it the perfect library to directly interact with vox files. Like you said it will enable us to use magicavoxel directly as a level editor. But I have a question about that. Since MagicaVoxel does not have a way to define attributes for instances (like game specific properties e.g. health, power, etc...). So we need to be able to have a stable id for object instances coming from vox files. Because we will have our custom scene format which will point to these objects coming from the vox files, and map our game specific properties to these ids. Do you have any recommendations? Do we just handle it manually (by using combination of name and instance id)? is model_id useful in this case?

Thanks

jpaver commented 3 years ago

Hey, thanks, sorry for the late reply and I hope you're finding the library useful!

Instance_id or model_id are not going to be stable, they could jump around with edits to the vox file, I'm afraid instance names and layer names are your best bet.

When I wrote about using it as a level editor I generally was thinking more of a tool to build the static environment for your levels, rather than the level logic such as spawns, patrol areas, trigger volumes etc.

But I suppose you could do it using a layer for gameplay, and using instance names as stable identifiers. Really, you'd have to decide on a convention, such as

  1. place all gameplay elements in the layer named "gameplay"
  2. Prefix enemy with "enemy[name][archetype]
  3. Prefix trigger volumes with "trigger_[name of script]" Etc...

Then basically your engine would map these names to externally defined properties as you mention.

Of course, these rules would become pretty complex with increasing gameplay complexity, which is generally why I personally prefer a wysiwyg in game level editor for quick iteration on placement and testing.

jpaver commented 3 years ago

@kariem2k question answered I think? Please feel free to reopen if you still need some advice. Thanks!