Can python do this?

Just wondering if possible to temporarily disable logic brick collision detection
Is there a script? I don’t think that can be done with logic bricks

digiman

I don’t think there is currently any way to disable collision detection on objects. I tried dynamically making game objects ghosts, but this didn’t work as the game object property is read only. Also, I don’t think it is possible to change an object’s physics type to “No Collision” at runtime. You can “suspendDynamics” and “restoreDynamics”, but this is probably not what you want.

A workaround that I used was to have two identical objects on a hidden layer with one set to “Ghost” and one without “Ghost” set. I then switch between these two objects using addObject() and endObject() at runtime, giving the same effect as toggling collision detection using “Ghost” but with possibly higher overhead than a simple “Ghost” toggle on a single object. This could be done with either logic bricks or a script.

This is pure speculation now, but this possibly has something to do with how the physics shapes are calculated by the game engine at startup and it was decided to leave objects as either collision or no-collision for performance reasons… Just guessing here though. :wink:

You could use states to switch the state of the object to another one that doesn’t have a logic brick collision detection - or just use Python to test to see if a value is true, and if so, then don’t check for collisions from the sensor.

Oh… Probably referring to touch sensor logic brick I read it and thought dynamics collisions. Joeman16’s reply is spot on. :wink:

You can set the collision sensor to look for a non-existent property:

collision_sensor.propName = "asdjksdddd" # disable
collision_sensor.propName = "" #re-enable

This wont actually stop the sensor (it will still be running consuming physics and logic time), it just makes it never fire a positive pulse. I think states would be the better route.

I made a quick blend which does not work with that script, of course i did something wrong. Let me know what i did incorrectly.On entering i want collision off then enable collision detection after about 15 seconds or so. By the way not sure if it is important but my objects will have an armature.
thanks

digiman

Attachments

collision.blend (132 KB)