Modify Hybrid Property
This tutorial will explain how to modify agent runtime properties in a hybrid workflow (a.k.a. game objects). For simplicity, hybrid mono components will be referred to as authoring components.
As the hybrid workflow internally runs entities for simulation, the runtime interaction with its properties is closely tied to entity logic. Each authoring component has getters and setters of its respective entity component. Usually, the property name starts with the Entity prefix.
Speed
For example, let's say you want to modify the Agent speed at runtime. To do this, you would check the AgentAuthoring component and for its property EntityLocomotion, it will contain fields related to locomotion, including the Speed.
Note
You might wonder why the field is not called EntityAgent. The reason is that the agent contains multiple entity components: Agent, AgentBody, and AgentLocomotion. Each of these components represents different logic it controls. This is quite a special case; other components tend to follow a similar naming convention between mono and entity components.
Here is how it would look like in code. Notice that EntityLocomotion is a value type and not a reference type, meaning you will need to assign back your modified structure copy!
var agent = GetComponent<AgentAuthoring>();
var locomotion = agent.EntityLocomotion; // Reads locomotion value into a copy
locomotion.Speed = 10.0f; // Modifies the copy
agent.EntityLocomotion = locomotion; // Writes back the locomotion value
Important
Accessing these entity properties will cause the main thread to wait for job threads to finish. It is recommended to minimize the usage of it.
Also, do not mix these properties with other very similar ones that start with the Default prefix. These properties are tied to editor logic and are default configurations which will be used to create the underlying entity.
var agent = GetComponent<AgentAuthoring>();
var locomotion = agent.DefaultLocomotion; // Reads editor locomotion value into a copy
Debug.Log($"My agent {agent} has an awake speed value of {locomotion.Speed}!");