Advertisement
dermetfan

Episode 24 annotations

Oct 3rd, 2013
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. http://youtu.be/Mn5rjsxWH_E?t=25m28s
  2.  
  3. When the player touches the bottom of a platform with his head and falls down, the velocity on Y is smaller than zero, so the collision filter lets them collide.
  4.  
  5. In postSolve, we let the player jump if he touches something, so he'll also jump if he touches the bottom of a platform with his head which is the reason he's getting stuck.
  6.  
  7. To fix this, check if he's actually touching the platform with his feet/the bottom:
  8. if(contact.getWorldManifold().getPoints()[0].y <= body.getPosition().y - HEIGHT / 2)
  9.  
  10. The WorldManifold contains information about the state the of the world. This includes the contact points which we get as a Vector2[] from getPoints().
  11.  
  12. We take the Y component of the first collision point and check if it's below or exactly on the bottom border of the player. If yes, he touches the platform with his feet and therefore should jump.
  13.  
  14. Finally, postSolve looks like this:
  15. if(contact.getFixtureA() == fixture || contact.getFixtureB() == fixture)
  16. if(contact.getWorldManifold().getPoints()[0].y <= body.getPosition().y - HEIGHT / 2)
  17. body.applyLinearImpulse(0, jumpPower, body.getWorldCenter().x, body.getWorldCenter().y, true);
  18.  
  19. The boost is fixed as well because the player now doesn't jump on a side contact anymore.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement