I have a question regarding setting up continuous collisions. I have a character in my game that will be firing an automatic weapon. I was hoping to be able to set up a collision so that, once the event begins, the firing will occur until the event has ended.
An abridged version of what I have so far is this:
local windowCollision = function(self,event) if event.phase == "began" and playerStats.ready == true and hud.ammoCount \> 0 then local thisWindow = event.target if thisWindow.isBroken == false then timer.performWithDelay( 25, function() playerHitArea.isBodyActive = false; makeCasing( player.x, player.y); end, 1) updateHudAmmo() playerStats.ready = false end timers.shot = timer.performWithDelay( playerStats.shotTime, function() playerStats.ready = true; playerHitArea.isBodyActive = true; end, 1 ) end end
This will fire two or three times before it stops and then I have to move the player and initiate the collision again.
Anyone got any ideas on how I can make this work (of do something better to achieve the result I’m looking for)?
Thanks!
Alan