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

Physics

Even though agents are simulated with physics, not all of the agent's physics parameters are enforced at the physics simulation level. The mass of an agent, for example, is the identical mass used within the physics simulation itself, while the MaxForce and MaxSpeed functions of an agent are only enforced by the agent. These two properties represent the maximum amount of force an agent can exert on itself and the max speed the agent can reach without any outside influences.

An intuitive example of why this separation is desirable when dealing with agent physics is gravity. When an agent accelerates to its max speed, we still want gravity to accelerate the agents downward in the case of falls. This acceleration can force agents to have a speed larger than their max speed property.

Mass

To access and modify the mass of our agents we can use the agent's GetMass and SetMass helper functions.

local mass = agent:GetMass();
agent:SetMass(mass);

The max force

The maximum force of our agents can be accessed and set using the GetMaxForce and SetMaxForce functions.

local maxForce = agent:GetMaxForce();
agent:SetMaxForce(maxForce);

The max speed

To set and access the max speed property of our agents, we can use the GetMaxSpeed and SetMaxSpeed functions.

local maxSpeed = agent:GetMaxSpeed();
agent:SetMaxSpeed(maxSpeed);

Speed

Setting and accessing the speed of our agents can be done through the GetSpeed and SetSpeed functions.

local speed = agent:GetSpeed();
agent:SetSpeed(speed);

Velocity

Similarly, to access and set the velocity of our agents, we can use the GetVelocity and SetVelocity functions.

local velocityVector = agent:GetVelocity();
agent:SetVelocity(velocityVector);
主站蜘蛛池模板: 平顶山市| 龙岩市| 舞阳县| 岳阳市| 德保县| 吉安县| 永修县| 文安县| 平塘县| 双城市| 玛纳斯县| 攀枝花市| 赣州市| 阳原县| 大荔县| 凉城县| 炎陵县| 达拉特旗| 民乐县| 商河县| 山丹县| 龙井市| 南汇区| 临城县| 舒兰市| 资阳市| 普定县| 阳高县| 济宁市| 凤冈县| 宣汉县| 上蔡县| 东山县| 七台河市| 司法| 定州市| 三河市| 丰台区| 奇台县| 牡丹江市| 建昌县|