[Working on] Relative entity paths

In the next Wave Engine version, we are introducing a new feature that can help improving your productivity.

We have decided to add relative entity path in our engine, allowing to obtain an entity just knowing its path from another entity.

This will be really helpful when you’re creating components that reference other entities and:

  • You don’t know the target entity’s absolute path.
  • Your component is used several times in your scene.
  • You want to make your component / entity reusable.

Path representation

These are the path representation elements:

  • Entity separator:  
  • Current entity:      
  • Parent entity:        

Sample uses

Giving the next sample entity hierarchy:


  • The relative path from wheel1 to tire2 would be:

  • The relative path from car to tire1:


Notice that  [this] is optional.

  • The absolute path of wheel1 entity would be exactly te one we’ve been using until now:
  • When you want to get an entity that doesn’t belong to the source’s root entity, we just specify the target’s absolute path. For example, the relative path from tire1 to ground is just:

Instead of

  • To figure out if a specific path is absolute or relative, we just have to read the first element. If it’s one of the special elements (‘.’, ‘[this]’ or ‘parent’) it’s a relative path. Otherwise, it’s an absolute one.

Additional methods

In order to make easier the search of entities in code, we’ve added the Find method in the Entity class.

public Entity Find (string path)


This method finds an entity with the desired relative path respect the caller entity. If the relative path is not correct, it returns null.

We have also added an additional parameter in the Find method in EntityManager class, allowing to set the source entity and allowing to directly search there.

public Entity Find (string path, Entity sourceEntity = null)

For example (following with the above-mentioned hierarchy), if we want to search the tire1 entity from car we can call one of the next :

Entity tire;
// We can find the entity either of these ways
tire = car.Find(".wheel1.tire1");
tire = this.EntityManager.Find(".wheel.tire1", car);


Until now, we had to use relative paths in code. This means that if we wanted to make the component robust, we should check for null.

Let’s imagine we are coding a component for the wheel1 entity and we want to use the tire2 class.


We should either:

  • Find it using the absolute path, which makes it harder to deal with when we want to make it reusable.
Entity tire = this.EntityManager.Find("car.wheel2.tire2");
  • Find it using the relative path by code.
// We are assuming the component owner is 'car'
// We are ignoring any null check
Entity tire = this.Owner.Parent.FindChild("wheel2").FindChild("tire2");


We just have to search the entity:

Entity tire = this.Owner.Find("[parent].wheel2.tire2");

Stay tunned because we are about to add more tools for making it easier the task of creating your components.

Leave a Reply

Your email address will not be published. Required fields are marked *