Game Development Reference
In-Depth Information
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