官术网_书友最值得收藏!

Agent properties

Now that we can create agents, we're going to take a step back and look at what properties are available to an agent and what they mean.

Orientation

Whenever you need to return the orientation of an agent, it's easiest to use the forward vector that usually represents the direction of movement of an agent. Both the left and up vectors of orientation are available as well. Whenever you need to change an agent's direction, simply set its forward vector.

The forward axis

To access and set the forward vector of our agents, we can use the built-in GetForward and SetForward helper functions.

local forwardVector = agent:GetForward();
Agent.SetForward(agent, forwardVector);

The left axis

We can also access the left orientation vector using the GetLeft helper function.

local leftVector = agent:GetLeft();

The up axis

Accessing the up orientation vector is similarly provided by a GetUp helper function.

local upVector = agent:GetUp();

Location

An agent's position is the center of the mass of its capsule representation within the physics simulation. If you need to determine the origin of an agent, simply return its position and subtract half its height from the y component of the position.

Position

To access and set the position of agents, we can use the GetPosition and SetPosition helper functions.

local positionVector = agent:GetPosition();
agent:SetPosition(positionVector);

Size

The size of the agent and their capsule representation is determined by the agent's height and radius. When changing these values, the physics simulation will also adjust and create a new representation for the agent based on the changes.

Height

Accessing the height of the agents can be done through the GetHeight and SetHeight helper functions.

local height = agent:GetHeight();
agent:SetHeight(height);

Radius

To access and modify the radius of an agent, we can use the GetRadius and SetRadius functions.

local radius = agent:GetRadius();
agent:SetRadius(radius);
主站蜘蛛池模板: 石河子市| 迁西县| 花莲县| 伊宁县| 永定县| 江达县| 买车| 连江县| 铜梁县| 东乌珠穆沁旗| 鄯善县| 辽宁省| 汝南县| 滨州市| 德昌县| 和田县| 洛川县| 长丰县| 禹城市| 马山县| 涪陵区| 英吉沙县| 桦川县| 双城市| 凤台县| 吉林省| 通辽市| 巴林右旗| 浮山县| 峨山| 永善县| 清丰县| 汉寿县| 延寿县| 开江县| 龙岩市| 黑龙江省| 历史| 民权县| 杭锦后旗| 都江堰市|