Climbing Game ? Multiple Gravity ?

I'm trying to find a way to make a b2body climg a mountain with many surface. (Ice, rock...) I tough of a way where you could have the game constituated of b2boxes with multiple vector applying force on the player(another box). But i'm not really if that's a good Idea and how to to that.

The game is still in an early stage of development but that's the kind of thing they wanted...

Thanks in advance !
Is it that no ones have an idea, or mine is stupid ?
I can't speak for anyone else, but I'm struggling to picture what you're trying to achieve.

A picture is worth a 1000 words 😉
Since there's no concept picture of the game (Yeah I know development is pretty sloppy :/) I'll try to explain the game better.

- The game would be separated in a multitude of tile having different indice of "grip".
- Those grips would affect the speed at which the player is climbing the mountain.
- I'll have a Stamina bar for the arms and legs of the player. Those Stamina bar will depleted while the player stay in place on a surface where he doesn't have a good grip.
- There's an ability to jump over surface that aren't climbable.

What I figured out as of now :

I would use box2d to move the player. Create a world with Zero gravity. Use box as sensors with a userData that would have a surface "indice". The player would be seperated in 4 box that would represent his 2 arms and legs.

My problem now is that, the mountain would be 2000px by 6000 px. and the surface grid would be about 5x5 px. I tried to explain to my superior (Who aren't flash programmer) than that would be kind of overkill to have that much box to check surface on but hell... If I ain't trying it they won't be acknoledging me.

Is there any other way you would see this to be done ?
Update, new Question :

I'm wondering, why is that when I listen to a contact... something like this :

Code:
      public override function Add(point:b2ContactPoint) : void {
         if (point.shape1.GetUserData().Name == "Player"){
            contactStack.push(new CustomListener(point.shape1, point.shape2));
         }
      }


I'm getting 2 new entry in my contactStack array ?
Some different ways to accomplish multiple gravities within a simulation:
http://www.emanueleferonato.com/2009/07 ... ith-box2d/

And as for your double-collision problem..

Perhaps the removecontact is not firing properly?
Perhaps the persist is adding another touch collision?
In some engines AtouchingB will produce AtouchesB & BtouchesA events
for the same collision.
Are you perhaps overriding something that's already going on elsewhere?

Personally, I get better performance disabling contact listeners, and using
a modified GetBodyAtMouse function but good luck either way =)
Since my contactListener is only overriding the Add function I'm kind of interested by you GetBodyAtMouse, but I'd like to find out which shape is overlapping which other shape, but only when I ask him to.
Uhm, If I remember correctly the meat and bones of the GetBodyAtMouse() function either came from the downloadable example, or from Emanuele Feronato's site..

It basically works by drawing a small (like 0.1 x 0.1) immaginary square and checking what's overlapping it...
It can be used to return multiple objects, but this one I'm pasting has obviously been tweaked to just
return the first.

Code:
public function GetBodyAtMouse(includeStatic:Boolean  ):b2Body {
            mouseXWorldPhys = mouseX / 30;
            mouseYWorldPhys = mouseY / 30;   
       mousePVec.Set(mouseXWorldPhys, mouseYWorldPhys);

       var aabb:b2AABB = new b2AABB();
            aabb.lowerBound.Set(mouseXWorldPhys - 0.01, mouseYWorldPhys - 0.01);
            aabb.upperBound.Set(mouseXWorldPhys + 0.01, mouseYWorldPhys + 0.01);
           
            // Query the world for overlapping shapes.
            var k_maxCount:int = 10;
            var shapes:Array = new Array();
            var count:int = m_world.Query(aabb, shapes, k_maxCount);
            var body:b2Body = null;
            for (var i:int = 0; i < count; ++i)
            {
                if (shapes[i].GetBody().IsStatic() == false || includeStatic)
                {
               
               
                    var tShape:b2Shape = shapes[i] as b2Shape;
                    var inside:Boolean = tShape.TestPoint(tShape.GetBody().GetXForm(), mousePVec);
                    if (inside)
                    {
                        body = tShape.GetBody();
                        break;
                    }
                }
            }
         
         
         
         
            return body;
        }// GetBodyAtMouse




So you can obviously just do a little modification.. i.e.

Code:
   public function getCloseBodies(targBody:b2Body){

       if (targBody != null){

            mouseXWorldPhys = targBody.GetPosition().x;
            mouseYWorldPhys = targBody.GetPosition().y;   
       mousePVec.Set(mouseXWorldPhys, mouseYWorldPhys);

       var aabb:b2AABB = new b2AABB();
            aabb.lowerBound.Set(mouseXWorldPhys - 0.5, mouseYWorldPhys - 0.5);
            aabb.upperBound.Set(mouseXWorldPhys + 0.5, mouseYWorldPhys + 0.5);
       }

  }




The advantage to doing it this way is that it can be slightly faster, with loads of objects
and only 2-3 important collisions, and you can increase the bounds slightly i.e. if the user
has to cick two objects that are *REALLY* close and appear touching, but aren't touching.
The disadvantage, I'm guessing it's less lightweight overall, so use sparingly, and the
collision detection doesnt take rotation into account.

Either way, have fun fiddling with it 🙂



Here's a few links I found:
http://wonderfl.net/search?page=3&q=b2MouseJointDef
http://wonderfl.net/search?q=body2&search_order=new
http://www.emanueleferonato.com/2008/11 ... x2d-flash/

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