Auditory events
Auditory events are created from the sandbox itself and are sent to all agents. It's up to the agent to determine what to do with the information, such as disregarding the event based on the distance.
The BulletShot event
To send an event when bullets are shot, we can update the ShootBullet
function to send out an event based on the bullet's shot position:
AgentCommunications.lua
:
AgentCommunications.EventType.BulletShot = "BulletShot";
Soldier.lua
:
local function SendShootEvent(sandbox, shootPosition) local event = { position = shootPosition }; AgentCommunications_SendMessage( sandbox, AgentCommunications.EventType.BulletShot, event); end local function ShootBullet(sandbox, position, rotation) ... SendShootEvent(sandbox, position); end
The BulletImpact event
An event similar to the BulletShot
event can be sent out when a bullet impacts a location:
AgentCommunications.lua
:
AgentCommunications.EventType.BulletImpact...