I'm new to LibGDX and Box2D, and I'm trying to create my player's body but got some issues.

I've created the ground as a ChainShape, and my player as a Rectangle. I want to attach a fixture for its feet, so I tried adding an EdgeShape but - correct me if I'm wrong- it seems that an EdgeShape cannot collide with a ChainShape.

Is there a proper way to create the player's feet? Should I change my ground from ChainShape to Rectangles or should I use some other shape for the feet?

Edit: Following DMGregory's advice, I've made some progress. Since my print statements won't be of much help, I'll post this link with a very detailed explanation: https://stackoverflow.com/questions/7459208/distinguish-between-collision-surface-orientations-in-box2d

And some background reading here: https://www.iforce2d.net/b2dtut/collision-anatomy

  • \$\begingroup\$ Is a rectangle for the player not sufficient for your case? Can you show us what your character and its collision shapes look like at the moment? \$\endgroup\$ – DMGregory Jul 5 '19 at 15:49
  • \$\begingroup\$ I'm just using a 32x64 rectangle at the moment. I have some moving platforms that I want to be activated when the player steps on them. Also potentially killing enemies by jumping on them. That's why I was thinking of a different fixture for the feet. \$\endgroup\$ – xmac Jul 5 '19 at 16:01
  • \$\begingroup\$ Checking the collision normal might be sufficient and simpler. \$\endgroup\$ – DMGregory Jul 5 '19 at 16:03
  • \$\begingroup\$ Thanks, I wasn't aware of this. I think I got something basic working with print statements at the moment. \$\endgroup\$ – xmac Jul 5 '19 at 19:25
  • \$\begingroup\$ If you've solved your problem, feel free to post your solution as an Answer. \$\endgroup\$ – DMGregory Jul 5 '19 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.