1
$\begingroup$

I am not sure if I am doing something wrong or there is an issue with the Collision sensor.

I have a sensor embedded on the floor, with 2 objects that are moving over it. If the two objects pass over the sensor at different times, then I can register them correctly, i.e. I can detect which hit the sensor and at what time.

However, if they step on the sensor concurrently, then I can only detect one and the other is never detected.

Here is the setup:

  • Objects 1 and 2 are identical with the following properties: Rigid Body, Actor and Ghost (I tried to also with this disabled, but did not change the behavior)

  • The python code at the sensor:

    own = cont.owner
    collision_detector = own.sensors["MyReader"]
    objects = collision_detector.hitObjectList
    if collision_detector.positive:
        print(own,' detected: \t',objects)
    

So when I have the two objects move over mydetector.000 one after the other, then I get:

    mydetector.000 detected       [Obj1]
    mydetector.000 detected       [Obj2]    

However, if one (sayObj1) is already onmydetector.000` and the other passes by then I get the following output:

    mydetector.000 detected       [Obj1]

and Obj2 is never detected. I would have expected the object objects to become a list, when both Obj1 and Obj2 are on top of mydetector.000, however this is not the case.

$\endgroup$
  • 1
    $\begingroup$ SOLVED: After installing 2.79, thinking of a 'bug' in 2.78c, I tried to enable the Pulse option in the Collision Sensor. That was worked out to resolve the issue. Now, when the two objects hit the sensor I get a list of objects, not just one (and not the other). Cool :-)! $\endgroup$ – geguze Oct 3 '17 at 21:10
  • 1
    $\begingroup$ You should post that as a answer below, with a short explanation of what you did and how and why it worked. $\endgroup$ – Duarte Farrajota Ramos Oct 4 '17 at 0:49
1
$\begingroup$

According to your own comment, the objects are not colliding at the same time (same frame).

Sensor triggering

All Sensor types will trigger the controller when:

  • The evaluation state changes from not positive to positive.
  • The evaluation state changes from positive to not positive.
  • [True Level Triggering] The evaluation state is positive after [Skip] frames.
  • [False Level Triggering] The evaluation state is not positive after [Skip] frames.
  • [Level] The state of the build-in state machine changes.

([Tab] and [Invert] manipulate the evaluation result. The trigger rules apply as above after that manipulation)

Applied to your observation:

f+0:

no object is detected -> sensor remains not positive no controller gets triggered

f+1:

the first object gets detected -> the sensor changes status from not positive to positive

according to the above rules -> the controller gets triggered The controller prints mydetector.000 detected [Obj1] to the console

f+2:

the first object still gets detected -> the sensor does not change state as it is already positive no rule applies -> no controller gets triggered

f+1+n:

The first and the second object get detected -> the sensor does not change state as it is already positive no rule applies -> no controller gets triggered

Sensors detecting multiple objects

With sensors that sense more than one object (collision, near, radar) you often want to know when the detected object set changes. Therefore they have an additional parameter [Pulse].

So you can consider following rule that applies on that kind of sensors:

  • [Pulse] the detected set of objects changes (e.g. other objects are detected/already detected objects are not detected anymore)

f+1+n:

The first and the second object get detected -> the set of detected objects changes (=new object detected) according to the sensor rule -> the controller gets triggered

The controller prints mydetector.000 detected [Obj1, Obj2] to the console

Solution

Switch on [Pulse]

(switch off [True Level Triggering])

$\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.