I’ve made a video on how to shoot bullets that destroy objects (enemies) in the Blender Game Engine. There is no python involved as well. I’ll leave the video below for those who are interested!
I do upload several Blender Game Engine videos a week, so if you want updates don’t forget to subscribe to my YouTube channel (Arsenal RSL)!
Ray(distance bullet travels per frame+margin)------python
import bge
from mathutils import Vector
cont = bge.logic.getCurrentController()
own = cont.owner
ray = cont.sensors['Ray']
if ray.positive:
if 'health' in ray.hitObject:
ray.hitObject['health'] -= own['Damage']
ray.hitObject.applyForce(own.worldOrientation.col[0]*100,0)
added = bge.logic.getCurrentScene().addObject('BulletImpact',own,0)
added.alignAxisToVect(Vector(ray.hitNormal),0,1)
own.endObject()
this will impart damage and knockback and add bullet damage sprite