1
$\begingroup$

I have a cube and a plane (cube is rigid body and plane is static). Add collision sensor to plane and attach python script [print ("positive")]. So it print positive when pluse is positive. Now I found that it send positive pluse only onces after game start. (it even did not detect collision with other object) So. How to use collision sensor to detect collision with all object.

$\endgroup$

1 Answer 1

1
$\begingroup$

A collision sensor sends only one positive pulse, as soon as its owner object collides with another object. To make it send pulses as long as this happens, you can use another script to reset the sensor as soon as it fires.

Here is the script I wrote:

import bge

cont = bge.logic.getCurrentController()

sns = cont.sensors['Collision'] # Whatever your sensor is called, not necessarily 'Collision'

sns.reset()

This script should be placed in a Python controller linked to the collision sensor in question (in the Plane object's logic). It will cause the other script to print "Hello" continuously until either 1) the game engine stops or 2) the object no longer collides with anything at all.

I hope this answer helps...

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .