Why my physics bodies pass through each other after a few collisions in spritekit?

Deadly 提交于 2019-12-11 06:49:13

问题


I am working on a game which involves a character jumping on plateforms like the Doodle jump game. The problem is the character will pass through the plateform after a few collisions with it. For jumping i use restitution player.physicsbody.restitution = 1.0 I apply force to the physicbody of character based on accelerometer data in update: method.


回答1:


You can try to use;

sprite.physicsBody.usesPreciseCollisionDetection = YES;

It is explained such as:

A small body might move so fast that it completely passes through another physics body without ever having a frame of animation where the two touch each other. If you have physics bodies that must collide, you can hint to Sprite Kit to use a more precise collision model to check for interactions.




回答2:


Hey man I had the same problem.

I had two limit nodes that were essentially bars that didn't move (isDynamic = false). I placed a moving bar between them and if I applied enough impulse, the bar would go through the limiting bars. I doubled the size of the limit bars so instead of being just 4 points tall they were 8 points tall.

After applying impulses way quicker than before, it seems the extra size made it possible for the computer to keep up and prevent the moving bar from passing through the limit bars.

\

OH. I also had to use the precise detection as well.



来源:https://stackoverflow.com/questions/24838465/why-my-physics-bodies-pass-through-each-other-after-a-few-collisions-in-spriteki

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!