Search code examples
blender

Adding "properties" to objects in a Blender scene


I am just starting my dive into Blender coming mainly from Quake's Radiant. I am trying to research whether it will fit the need I have for a level editor replacement. So with that in mind, here is my question:

What is the best method for creating and storing a set of prefab "entity" objects such as health packs, ammo pickups, and "moveable" objects such that they have a set of "properties" that can be changed within Blender?

I have found this page, but I am still getting lost as to how to integrate them on a per object basis and achieve the desired result: https://docs.blender.org/manual/en/dev/editors/properties_editor.html

Note: It is not my goal to use the Blender game engine - just attach values to things for me to export to my own engine.

Edit1: Found an article discussing the topic although it seems very outdated: https://www.gamasutra.com/blogs/IwanGabovitch/20120524/171032/Using_Blender_3D_as_a_3d_map_editor_rather_than_programming_your_own_from_scratch.php

Example:

// entity 105
{
"inv_item" "2"
"inv_name" "#str_02917"
"classname" "item_medkit"
"name" "item_medkit_11"
"origin" "-150 2322 72"
"triggerFirst" "1"
"triggersize" "40"
"rotation" "0.224951 0.97437 0 -0.97437 0.224951 0 0 0 1"
}

enter image description here


Solution

  • While we can manually add custom properties to any object, these are added to the specific object so can be unique to each object.

    A better way of integrating new properties is to use bpy.props, these can be added to an objects class in blender, this means every object will have the same properties available.

    You can setup a custom panel to edit your properties, like this simple example. Both the properties and panel as well as your object exporter can be defined in an addon which you can have enable at startup so that it is available every time you run blender. An addon also makes it easier for you to share your game editor with others.