Jump to content

Object property access while game init


photo

Recommended Posts

We use Node::getProperty() to determine different object types (game logic). We do it when player intersect with this objects, and we do it in world init() function when Unigine is startup.

For example, we have one game object, that we use many times in world. So, we add property to node file, and then we use this node like NodeReference, but in this case Node::getProperty() return NULL. But when I use intersection algorithm, and engine.world.getIntersection() return an object (NodeReference too), then Node::getProperty() return right filled property.

Question: how get property from nodes, that we inserts in world like NodeReferences? Thanks

Link to comment

NodeReference is a fake container Node.

 

If you have an Object you can get it's NodeReference by using following function:

NodeReference get_reference(Node node) {
 while(node != NULL) {
  if(node.getType() == NODE_REFERENCE) return node;
  node = node.getParent();
 }
}

 

If you have a NodeReference you can get it's internal node by calling NodeReference::getNode() function.

 

There are two approaches:

The first one is to store properties inside the NodeReference.

The second one is to store properties inside the NodeReference internal node.

We use first approach in OirRush game because it's more simple for level designers and more configurable.

Link to comment
×
×
  • Create New...