Sites

Menu

Creating queries

In the new Inspector, you can find queries and constraints in the query editor module, and you use them to define and restrict which entity data is streamed from your deployment.

You create queries using one or many constraints that you can combine with each other. This is essentially the same querying mechanism as query-based interest, just with a visual interface.

Constraint types

Compositional constraints

You can use these constraints as building blocks to link other constraints together and build complex queries.

Constraint type How it works
AndConstraint For an entity to appear in the query result, all of the sub-constraints must be true.
OrConstraint For an entity to appear in the query result, one or many of the sub-constraints must be true.
NotConstraint This constraint negates anything that is attached to it as a sub-constraint. For example, you could attach an EntityIDConstraint to show all entities but a specific one.

Spatial constraints

Spatial constraints only return entities whose positions are in the area defined.

Constraint type How it works
BoxConstraint This constraint defines a box in your game world. You can define it by defining two (opposite) corners of the box.
SphereConstraint This constraint defines a sphere in your game world. You can define it by selecting a center point as well as a radius.
CylinderConstraint This constraint defines a cylinder in your game world. You can define it by selecting a center point as well as a radius - its top and bottom bounds are infinite.

Entity and component constraints

You can use these types of constraints to filter for specific entity characteristics. This can help you narrow down a query to only specific kinds of entities.

Constraint type How it works
ComponentConstraint This constraint returns only the entities that have the specific component attached to them. If you have an entity that has a unique component attached to it, (for example, if only player entities have the PlayerController component) you can use this constraint to filter for only this kind of entity.
EntityIDConstraint This constraint returns only the entity with that specific entity ID. You could use it to find a specific entity in your game world.
AuthorityConstraint This constraint returns only the entities that have components the specified worker has write access authority over.

For example, to see which entity components a worker has write access authority over, use this constraint to specify this workere via its worker_id.

Non-conditional constraints

Non-conditional constraints act as a catch-all for situations where you do not want your query (or sub-query) to depend on a condition.

Constraint type How it works
TrueConstraint This constraint always returns all entities.
FalseConstraint This constraint always returns no data.

Using constraints

You can find constraints in the query editor module. You can create only one query per query editor module. You can add, modify, remove, or move constraints to create the query.

Adding a constraint

To add a constraint, choose the type of constraint in the query editor module.

Modifying a constraint

To modify a constraint, change the input that defines it.

Removing a constraint

To remove a constraint, click its drop-down menu and select Delete.

You can’t remove dynamic constraints. Instead, you must delete the connection that links the dynamic constraint with the query editor module. To do that, turn on Edit mode and click the icon in the centre of the connection.

Moving a constraint

You can move constraints around by dragging them. This is useful when you want to change the nesting structure of your query.

Dynamic constraints

You can dynamically pass a constraint to a query editor module, and it is added to the query. For example, to constrain a query by the bounds of a viewport, you can pass in these bounds as a constraint.

To do that, turn on Edit mode and output the constraint from the viewport into the query editor.

Note: Constraints that are passed in dynamically are marked with a locked icon. This means that modification is limited (the constraint is set dynamically by the module that is passing it in). You can, however, still nest and re-order these constraints.

Streaming components

You can choose the components that you’re interested in and only these components and their values are returned in your query. This helps you manage the amount of entity data that is being processed and streamed.

To add components for streaming, in the Components streamed section of the query editor, complete the following steps:

  1. Select Custom and click the plus (+) sign to show all the available components.
  2. For any component that you have interest in, click the plus (+) sign after the component name.
  3. Close the Add Components window.
  4. Click Run query to start your query with the selected components streamed.


————
2019-11-25 Page updated with limited editorial review: added AuthorityConstraint

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums