I have a problem with a game I am making. I am using physics and have 2 objects, and enemy and a turret. I have a body radius set on the turret which is a sensor. The collision kind of works but it only works when the enemy hits the radius and when exiting the radius. How can I continue to track the enemy when it is inside the sensor so i can carry on firing? Some example would be good if possible
Thanks
That’s how the physics engine works, it only catch certain events: “collision:, “preCollision”, and “postCollision”.
for “collision” there have 2 phase: “began” and “ended”, that’s why your turret only fire when the enemy hit and exit the radius.
My suggestion is: you can setup a timer when the enemy hit the radius, the timer will call the firing function. while the enemy exit the radius, stop and clean the timer.