Reader small image

You're reading from  Learning Game AI Programming with Lua

Product typeBook
Published inNov 2014
Reading LevelBeginner
PublisherPackt
ISBN-139781783281336
Edition1st Edition
Languages
Right arrow
Author (1)
David Young
David Young
Right arrow

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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Game AI Programming with Lua
Published in: Nov 2014Publisher: PacktISBN-13: 9781783281336

Author (1)