So you are executing the code when the object is NoneType (hand.hitObject == None) when you have to do the opposite, use =! instead or just check directly: if hitObject. Also you have to check if the object have the property “damage” if you doesn’t use a property in the sensor.
hitObject = hitSensor.hitObject
if hitObject:
if "my property" in hitObject:
do somenthing
def Tree():
scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
own = cont.owner
selector = scene.objects['HotBarSelector']
rayItem = selector.sensors['Ray']
rayType = selector.sensors['Ray.002']
rayDamage = selector.sensors['Ray.001']
leftMouse = own.sensors['LMouse']
mouseOver = own.sensors['MouseOver']
if leftMouse.status == bge.logic.KX_INPUT_ACTIVE and \
mouseOver.status == bge.logic.KX_INPUT_ACTIVE and \
rayItem.hitObject == None:
own['health'] -= 1
if leftMouse.status == bge.logic.KX_INPUT_ACTIVE and \
mouseOver.status == bge.logic.KX_INPUT_ACTIVE and \
rayItem.hitObject != None:
own['health'] -= rayDamage.hitObject['damage']
On the last line, it should subtract the value of damage from the owm[‘health’] in this case the owner is a tree and when the player is holding an item with a damge value it should use that value otherwise just damage by 1, every object in my game has a damage value, and the rays are set to check specifically for these items but i keep getting the same error “NoneType is not scriptable” and i cant seem to figure this out
Thank you for all the feedback. What im trying to achieve is quite simple, when the player (in a flat 2 world) mouses over and clicks a tree it should affect the trees damage based on whats in the items hand. The rays stem from a piece of GUI which hovers over the active item (item in hand)
all of my ray sensors are checking for the properties specifically, and each item has these props. so the only things being hit by the rays are items with these props, or nothing at all. I can get it to a point with no errors in the console but it still doesnt work, my brain hurts.