I am creating a shooter game that will rely a lot on ricochet, but the bullets usually pass through my walls(unless they hit it at a slant, in which case they travel along the platform, not bounce off of it).
the bullets seem to interact with each other, just not the other static objects.
I need to be able to shoot projectiles at slow to high speeds and have the bounce off every static object
until they slow down and stop.
What should I read up on to to get my bullets bouncing around?
This is basically what I am using, Thank you for taking a look.
Local physics = require(“physics”)
physics.start()
–physics.setGravity()
–physics.setDrawMode(“hybrid”)
local gun = display.newImageRect( “gun.png”, 80,80)
gun.x = 100
gun.y = 100
– Shoot the bullet when the player touches the fire button.
local function onTouch( self, event )
if( event.phase == “began”) then
local bullet = display.newCircle(0,0,11)
bullet.x = gun.x
bullet.y = gun.y
physics.addBody(bullet, “dynamic”,{bounce=5})
bullet.isBullet = true
transition.to(bullet, {x=1000, onComplete=function(obj) display.remove(obj); end})
end
end
– Create a rectangle that represents the fire button
local fireButton = display.newRect( 100, 200, 50, 50 )
fireButton:setFillColor(1,1,0)
fireButton.touch = onTouch – assign .touch to function onTouch
fireButton:addEventListener( “touch” )
local target = display.newRect(350, 200, 50, 300)
physics.addBody(target, “static”,{bounce=2})