Python\collision problem.

Hello there, I was trying to detect the collision between two static objects but ended up turning one into a sensor. Anyway, I made a little test file where the sensor goes through a static object while having a python script connected to the sensor.

Everything works fine. But if if I add a third object, and connect the script to it (and change it accordingly) then it won’t detect the collision. All, I did was to replace the owner part with a scene.objects[…]

It doesn’t give me any errors or anything but it also doesn’t work…

The two scripts are k.py and cam.py… k.py is supposed to print “Done” and change the property VAR to 1337… all that works, but cam.py is supposed to print “1337” when it detects the same collision, yet nothing happens, no error mesage, nothing…

Perhaps someone could have a look at the blend file?

Thank you.

Attachments

untitled.blend (137 KB)

I’m guessing that you wanted the cube to do something when it collided with the larger box. So I’ve rewritten it to make it stop. I’ve removed everything that wasn’t necessary and was making things more difficult or not working. Move the cube with the right arrow key.

Also I highly recommend going to 2.53. If you open untitled253.blend in 2.53 by clicking on the file from Windows explorer I think you’ll find that it will start 2.53 with GUI settings that you are familiar with.

Attachments

untitled253.blend (346 KB)untitled249.blend (135 KB)

Thank you, but thats not what I was exactly looking for. My fault, for forgetting to mention that this was just a test file I did and not explaining it in a better way… :s

The whole purpose of it was to detect the collision on the third object. Which isn’t one of the 2 objects who are colliding. Like if A and B are colliding, then C will have be the one using the script that checks if A is colliding with B or not.

The problem is that this isn’t working and I have no idea why. :frowning:

Yo Shadox. Yeah I figured it’s a test and I don’t pretend to know what you wanted to do exactly. I know you’re dying to be able to pass variables and property values between objects but you are making a lot of errors and guesses. It took me a while to figure out the basics and I’ve still got a lot to learn yet.

Np… the funny thing is that I actually got it to work somehow in my real project, but I can’t do it in the test one to show you the result…

I hate it when things like that happen. You get it to work, but you have no idea why its even working… :frowning:

You have to keep in mind, that the collision sensor triggers the controller.
So you need a connection between the object that holds the collision sensor (sensor object)and the object that holds the actuator (action object).

There are some possibilities if this objects are separate:

1.Direct connection
Connect the sensors object collision sensor with a controller of another object (even the same object would do the trick). Connect this controller with the actuator at the action object.
Disadvantage:

  • The connection can’t be changed at runtime.
  1. Message
    Connect the sensors object collision sensor with a controller connected with a message controller sending a message to the action object.
    The action object senses for messages from the sensor object.
    Disadvantage:
  • The action sensor acts late (one logic tick behind).
  1. Script/Property:
    Connect the sensors object collision sensor with a Python controller.
    The Python controller looks for the action object and sends it a signal to activate the actuator.
    Disadvantages:
  • the action object’s controller might be processed already, making it impossible to activate the actuator at the same frame. So there is a 50% chance that it is late as well (1 frame).
  • the action actuators controller might not be activated at all, because it did not received a signal from a sensor.
    [LIST]
  • Solution: set an property at the action object. A property sensor can activate the actuator
  • Disadvantage -> it will be late (1 frame)

[/LIST] I hope it helps