Cocos2D-JS Chipmunk: One-way platforms?

Discuss new features and future development.

Cocos2D-JS Chipmunk: One-way platforms?

Postby jem » Tue Apr 28, 2015 3:27 pm

Hello!

I've started using Cocos2D-JS to port my ObjC/Box2D game. I had to drop B2D and start using Chipmunk. It's great so far. Only thing I can't implement properly is the one-way platform.

Say body "A" is the platform and body "B" is the player. The preSolve phase allowed me to check that:
- B's lowest vertex is at least higher than A's topmost vertex.

This no longer seems possible since it seems (and I most certainly have missed something!) that Box2D provides the source position of both bodies and Chip provides the target position.

n.b. I've found the Unity tutorial https://chipmunk-physics.net/unityDocs/Tutorials/oneway.html and hoped it would work the same with the JS version. Apparently it doesn't seem to work the same (or I just missed something obvious) as I'm always returned the number 1 for the following:
arbiter.getNormal(0).y

Guidance to properly implement this is very welcome :-)

NB my "solution" so far is to make sure that body B hasn't gone deeper than 10% of its height below body A's surface. Works for low-speed objects. High-speed ones just go through most of the time.
jem
 
Posts: 1
Joined: Tue Apr 28, 2015 2:45 pm

Return to Features/Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron