In my game ,I have a gun which is attached to vehicle.Gun and vehicle are joined using a “WELD” joint.
I want my gun to shoot bullets in the direction that the gun now points to.
But gun shoots bullets in only one direction.
Here is my code
function fireBullet(event) local bullet=display.newRect(gun.x+20,gun.y,50,10) bullet:setFillColor( 0,0,0 ) camera:add(bullet,1,false) physics.addBody( bullet,{density=3.0, friction=0.5, bounce=0.05,isSensor=true ,isBullet=true}) bullet:applyLinearImpulse( 1000 , 0, gun.x,gun.y ) end
- How to shoot the bullets in the current direction of gun?
- How to shoot the bullets towards a particular object?
Thanks
