Handling auditory events
Handling auditory events requires you to add additional time-to-live information to each stored event. As a large number of bullet shots and impacts events are emitted, the time-to-live information will be used to prune out old events:
AgentSenses.lua
:
local function HandleBulletImpactEvent( userData, eventType, event) local blackboard = userData.blackboard; local bulletImpacts = blackboard:Get("bulletImpacts") or {}; table.insert( bulletImpacts, { position = event.position, ttl = 1000 }); blackboard:Set("bulletImpacts", bulletImpacts); end local function HandleBulletShotEvent(userData, eventType, event) local blackboard = userData.blackboard; local bulletShots = blackboard:Get("bulletShots") or {}; table.insert( bulletShots, { position = event.position, ttl = 1000 }); blackboard:Set("bulletShots", bulletShots); end
We can now add our auditory...