wck ContactList

hero extends shapes.circle

i create a new ContactList like this

Code:
contacts = new ContactList();
contacts.listenTo(this);



i have tried
Code:
contacts.update();

and
Code:
contacts.clean();


before and after jumping. still seems to act odd.

so i told it to flip scaleX of all bodies on the contact list with each jump (each wall is a seperate shapes.Box body.)
please notice that there are often many walls being flipped that the hero is no where near in contact with.

am i doing something wrong or is ContactList broken in some way?

i tried the dot manifold system that was in the demo boxMan, and currently have dumbed it down to isGround (which each horizontal wall is set to true) and then i noticed there were walls in my contact list that im not near.
Code:
private function canJump():Boolean{
   if(getTimer() - jumpDelayCount < jumpDelay) return false;
   
   var manifold:b2WorldManifold = null;
   var dot:Number = 9.5;
   var isGrounded:Boolean = false;
   
   if(!contacts.isEmpty()) {
      contacts.forEach(function(keys:Array, c:ContactEvent) {
         var otherShape:* = c.other.m_userData;
         var otherBody:* = otherShape.body;
         
         if(otherBody.isGround){
            isGrounded = true
         }
         otherBody.scaleX *= -1
         
      });
   }
   return isGrounded;
}


i will probably switch back to the dot manifold system which checks the direction of the contact after i get the contact list issue resolved. currently I'm not able to make heads or tails of this.

thanks for your time, hope I'm just missing something silly.
Make sure you've set both reportBeginContact and reportEndContact:
Code:
reportBeginContact = true;
reportEndContact = true;

That's the first thing I can think of that would result in false contacts.

contacts.clean() should be called EVERY timestep, once you're done processing contracts. It'll remove contacts that have ended that step. The reason you call it AFTER processing contracts, is you may want to process contacts created / destroyed in the same step (bullets, etc.). If you don't care about those you can just call contacts.clear() whenever.

You shouldn't need to call contacts.update(). There are certain cases where contact info is "stale" after a timestep and this will make sure the contacts are synced up with what you see visually.
can you recommend what code to use to make this call every time step?
would i override something in the bodyshape or in the main class that extends WCK
currently my code doesn't touch the time steps from what i see.
begining and end contacts events seem to have helps a ton. and i call contacts.clean() on EnterFrame. until i know more about how to do it directly on the time steps. seems to be solved. thanks a ton!
The BoxMan class sets up a timestep listener in its create() function:

Code:
listenWhileVisible(world, StepEvent.STEP, parseInput, false, 10);


listenWhileVisible is just a wrapper for addEventListener. So it's calling the "parseInput" method every timestep. Within that function is:

Code:
contacts.clean();


The STEP event is dispatched from the world, within an ENTER_FRAME listener, so essentially you are doing the same thing. The only difference is the STEP event wont be dispatched if the world is paused.

So I'm guessing you just forgot to set reportEndContact; thus the extra contacts. If you need any more info you have my IM.
perfect. Thank you.
can you think of a reason this would break when using shapes inside a BodyShape?

i seem to get
contacts.isEmpty(): false
contacts.num: 0
A quick search reveals that "num" variable isn't even being used. I must've used it at some point but forgot to remove it. I'll take it out.
it also seems that the forEach doesn't trigger, meaning that there are no contacts, despite isEmpty being false most of the time (even when in the air)

it worked well when my hero was the circle, but now that my hero contains a circle and a rectangle it doesn't work well, perhaps im missing something that is shape only and not body related.
I seem to be having a similar problem with ContactList data. My character has sensors to his left and right, so that when the player wants to grab hold of an object, whatever one of those sensors is touching gets attached to the player with a joint. This is working fine, except that for some reason, the object in those sensors' ContactLists is sometimes nowhere near the player.

I am already calling contactList.clean(); on the world StepEvent.STEP

Original thread: https://box2d.org/forum/viewtopic.php?t=5649