shoot enemies

How do you use a ray sensor to shoot a enemy either with logic bricks or python?

When your gun fires, you get the gun position and orientation and cast a ray from there. The ray cast function will return the first object that it hit. I think this can be filtered with a property. So ray-cast tells you the first object it hit with a given property (lets say a property called “enemy”).

If your ray returns a valid object then you take the appropriate action. i.e. message the enemy it was hit, or decrease it’s health directly.