ios - SpriteKit - Why my bouncing ball passes through the ground? -
i'm working small bouncing ball game using spritekit physics engine. problem is:
when apply huge impulse on bouncing ball have fall on ground fast, may pass through ground (very thin, height=2).
i find in apple document, doesn't work.
specify high precision collisions small or fast-moving objects when sprite kit performs collision detection, first determines locations of of physics bodies in scene. determines whether collisions or contacts occurred. computational method fast, can result in missed collisions. small body might move fast passes through physics body without ever having frame of animation 2 touch each other.
if have physics bodies must collide, can hint sprite kit use more precise collision model check interactions. model more expensive, should used sparingly. when either body uses precise collisions, multiple movement positions contacted , tested ensure contacts detected.
ship.physicsbody.usesprecisecollisiondetection = yes;
you can set sprite's node.physicsbody.usesprecisecollisiondetection = yes;
not guarantee collision flag time sprite's velocity high.
you should apply speed limit nodes prevent them going fast. this:
if(node.physicsbody.velocity.dx > 200) node.physicsbody.velocity = cgvectormake(200, node.physicsbody.velocity.dy);
the above code example limit right movement, dx, of node 200 while keeping dy (up/down) velocity is.
Comments
Post a Comment