Hello!
Today I’m trying to only have my player take damage if he collides with an enemy sword and the sword’s property “votile” is TRUE.
Here is my code so far:
import bgeimport GameLogic
cont = bge.logic.getCurrentController()
own = cont.owner
coll = cont.sensors["Collision"]
badsword = bge.logic.getCurrentController().sensors["Collision"].hitObject
vot = badsword["votile"]
if coll.positive:
if vot == TRUE:
cont.activate("damage")
With this code, I get an error that says “nonetype object is not subscriptable”
I suppose that import bge and import GameLogic are not together like that. Why do you even need to import GameLogic, anyway?
Also, are you sure that con.activate works like that? Shouldn’t you do damage = cont.actuators[“Damage”, cont.activate(damage) EDIT: Alright, you can do it that way…
Ah, yes, as Daedalus said, you should probably do something like this:
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
coll = cont.sensors["Collision"]
if coll.positive:
badsword = bge.logic.getCurrentController().sensors["Collision"].hitObject
vot = badsword["votile"]
if vot == TRUE:
cont.activate("damage")