sprite kit - Spritekit how to not veer off -



sprite kit - Spritekit how to not veer off -

i'm building pacman style maze game. can apply impulse , limit whatever vertical or horizontal direction desired on hero.

however, when add together physics body sprites walls, gets weird. have set hero physics body , walls have no bounce.

running head on wall stops dead expected. if alter direction , move along wall veer off @ slight angle wall. ideas causes , how avoid it? want move in vertical , horizontal straight lines.

ok solution here counter intuitive. rather using applyforce: or applyimpulse: family of methods on physicsbody, utilize runaction:forkey: on sprite itself. alter in direction, removeaction:forkey: before calling runaction:forkey: maintain things orthogonal. (otherwise there brief angular motion )

the other trick here find appropriate speed distance. fast , fly through walls. (bug?) apply speed , distance multiplier based on size of scene. total distance should greater possible in direction. keeps thing moving until hits wall or tell move in different direction.

this works well.

using physics body movement, seems best suited platformer situation have gravity.

in top downwards view, there isn't gravity. ( though imaginable want exerts gravity on sprite suck in)

sprite-kit

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -