1
$\begingroup$

When spawning an object into a game, I check its hit objects from my master python script, accessing the object spawned in.

For some reason, the "Collision" sensor does not exist in the object, although I can put any controller into the object and that is accessible.

Heavily simplified code to explain what's going on:

c = bge.logic.getCurrentController()
o = c.owner
s = o.scene

sph = s.objects["Sphere"]

col = sph.sensors["Collision"]
# doesn't work

a = sph.controllers["And"]
# works for some reason

col = a.sensors["Collision"]
# also doesn't work

The code worked a few days ago, but has mysteriously stopped working and I am at a loss as to what's going on. Any ideas would be greatly appreciated.

When looking at the object, it may have controllers, but the actuators and sensors both return an empty list.

Edit: I had disabled collision on the object, please do not make the same mistake as me.

$\endgroup$
  • 3
    $\begingroup$ Instead of adding Solved in title please write an answer to your question and in some details outline how did you solve it. You can mark the answer as accepted then $\endgroup$ – Mr Zak Mar 4 '18 at 15:27
0
$\begingroup$

So, apparently I need to add an answer to mark it as solved.

Basically, if your object doesn't have collision enabled in physics, it cannot use the collision sensor. Sounds pretty obvious, but it's easy to forget about it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.