I want this to be, Mouse right down, and click left mouse
if mouseLeftButton.positive: if ray.hitObject:
hitObject = ray.hitObject
this is full code
import bgeimport mathutils
scene = bge.logic.getCurrentScene()
space = 0.003
def rayLoop(cont):
#Sensors
ray = cont.sensors["ray"]
mouseLeftButton = cont.sensors["mouseLeftButton"]
mouseRightButton = cont.sensors["mouseRightButton"]
#Actuators
bullet_hole = cont.actuators["bullet_hole"]
if mouseLeftButton.positive:
if ray.hitObject:
hitObject = ray.hitObject
#Convert some values of the ray sensor to vectors
positionVector = mathutils.Vector(ray.hitPosition)
normalVector = mathutils.Vector(ray.hitNormal)
#Add the Bullet Hole
bullet_hole.instantAddObject()
bullet_hole = bullet_hole.objectLastCreated
#Adjust the bullet hole
bullet_hole.alignAxisToVect(normalVector, 2, 1)
normalVector.magnitude = space
bullet_hole.worldPosition = positionVector + (normalVector)#(positionVector + normalVector)
if "health" in hitObject:
bullet_hole.setParent(hitObject)
hitObject["health"] -= 15