Ok so I figured it out finally. Actually I figured it out a few hours ago and have been too busy playing with it to share
😀 I didn't think very many people would be up to notice yet anyhow though. So here's what I did to get
sensors working. Basically the beginning part is exactly as NintendoBen said with creating the two boolean "sensor" and "m_sensor" variables and setting the one to false in the constructor as I repeated in my previous post.
For the second part though I got rid of what I had added to b2ContactManager in the "Collide" function since this seemed to make the
sensors not show up on my contact list at all. I found what I believe is the correct spot in b2World.as, in the Step() function. You have to scroll down a little in the function to around the comment that says "Search all contacts connected to this body." This is what the code in the section where I changed looks like:
Code:
// Search all contacts connected to this body.
for (var cn:b2ContactNode = b.m_contactList; cn != null; cn = cn.next)
{
if (cn.contact.m_flags & b2Contact.e_islandFlag)
{
continue;
}
if (cn.contact.m_shape1.m_sensor == false && cn.contact.m_shape2.m_sensor == false)
{
island.AddContact(cn.contact);
cn.contact.m_flags |= b2Contact.e_islandFlag;
}
other = cn.other;
if (other.m_flags & b2Body.e_islandFlag)
{
continue;
}
The only thing I changed was to add the second "if" statement, but the two lines inside it are there to begin with, just without the if. Keep in mind this is working from version 1.4.2. I have tested it and it is working with two separate tests. One is deleting all objects that come into contact with the sensor, and the other is applying an upward force to objects within the sensor.
All I know is that this works visually in that objects can pass through the sensor, and the sensor has the desired effect on those objects. I'm not absolutely sure that there isn't some hidden bug effect at work here, or that I'm coding this in the most efficient way. Actually I wasn't even sure of what needed to be in the "if" statement except AddContact seems to be what puts the contacts into the list for the b2ContactSolver. Maybe that should be a continue statement inside the "if" instead, I'm not really sure. Erin or maybe Skatehead probably would know better
😉