Is there a way how to collide with an object with no collision?

What I’d like to do is to parent a static object with an empty object with no collision.
I can parent these objects when I add them to the scene through python. But there are going to be more copies of the objects and I would like to parent these objects when they are in the same position.
Since these objects can’t collide normally, is there a way how to do it with python, even though there will be several copies of these objects and each object would act individualy?

Sure. Any object with physic-type other then ‘no collision’ that has ‘ghost’ option turned on will still detect collisions, just not physically react to it.
Example, a security laser-trip-wire detects intruders but doesn’t physically trip them.
Also, the ‘sensor’ physic-type does the same function mentioned above - ‘no collision’ while still detecting collisions.

1 Like

Yes, you are right, this would definitely do the trick.
The thing is, the sensor physics type is more processor demanding, at least I think that’s the case.
If I had, let’s say hundreds of these, how would the game perform?
I’d like to parent these objects only when the player is next to them, so nothing else would trigger this. Is there no other way to do this with python?

1 Like

You could be well right, not sure myself.

Depends on whether the objects are ‘group-instances’, ‘batch-groups’ or single ‘duplicated-meshes’.

I would recommend putting a game-property on all the objects you want to be parented if in range.
For example I’ll call the imaginary property ‘child’.
Add a near sensor on your player - set the property checking value to ‘child’.
Then, with Python, have it so whenever the near sensor is activated, to parent the hitObject of the near sensor (A object with the child property) to be parented to the player.


  • Parent-Player.
import bge

def parent(self):

  if self.sensors["Near Sensor Name"].positive:
    self.sensors["Near Sensor Name"].hitObject.setParent(self.owner)

You would also need to run some code for the unparenting for the children(s).

Thank you for your suggestion. This would work 100%, but I would like to somehow script it without using the physics sensor to save on processing. Maybe when the player collides with the static object, then it could somehow search for the nearest empty object-based on a distance.

There is the KX_GameObject function self.owner.getDistanceTo().
You’d probably need to check every object in the scene to see if they have the right property like with sensors.