public static bool beginCollisionWithPlayer(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; arbiter.GetShapes(out shape1, out shape2); Goomba goomba = shape1.GetComponent <Goomba>(); Player player = shape2.GetComponent <Player>(); if (goomba.dieAnim.isDying() || player.isDying()) { arbiter.Ignore(); // avoid the collision to continue since this frame return(false); // avoid the collision to continue since this frame } goomba.idle.setIdle(true); // if collides from top then kill the goomba if (GameObjectTools.isHitFromAbove(goomba.transform.position.y, shape2.body, arbiter)) { goomba.die(); // makes the player jumps a little upwards player.forceJump(); } // kills Player else { arbiter.Ignore(); // avoid the collision to continue since this frame LevelManager.Instance.loseGame(true); // force die animation } // Returning false from a begin callback means to ignore the collision response for these two colliding shapes // until they separate. Also for current frame. Ignore() does the same but next frame. return(true); }
public static bool presolveCollisionWithOneway(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; // The order of the arguments matches the order in the function name. arbiter.GetShapes(out shape1, out shape2); // if collision was from below then continue with oneway platform logic if (GameObjectTools.isHitFromBelow(arbiter)) { arbiter.Ignore(); return(false); } Player player = shape1.getOwnComponent <Player>(); // if player wants to climb down (once it is over the platform) then disable the collision to start free fall if (player.GetComponent <ClimbDownFromPlatform>().isClimbingDown()) { player.jump.reset(); // set state as if were jumping arbiter.Ignore(); return(false); } // let the collision happens return(true); }
public static bool beginCollisionWithPlayer(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; arbiter.GetShapes(out shape1, out shape2); KoopaTroopa koopa = shape1.getOwnComponent <KoopaTroopa>(); Player player = shape2.getOwnComponent <Player>(); if (player.isDying()) { arbiter.Ignore(); // avoid the collision to continue since this frame return(false); // avoid the collision to continue since this frame } bool collisionFromAbove = GameObjectTools.isHitFromAbove(koopa.transform.position.y, shape2.body, arbiter); if (collisionFromAbove) { // if koopa was jumping then stop forever jumping if (koopa.jump.isJumping()) { koopa.stopJumping(); } // hide the koopa troopa or stop the bouncing of the hidden koopa else if (!koopa._hide.isHidden() || koopa.bounce.isBouncing()) { koopa.hide(); } // kills the koopa else { koopa.die(); } // makes the player jumps a little upwards player.forceJump(); } // koopa starts bouncing else if (koopa._hide.isHidden() && !koopa.bounce.isBouncing()) { koopa.stop(); koopa.bounce.bounce(Mathf.Sign(koopa.transform.position.x - player.transform.position.x)); } // kills Player else { koopa.stop(); arbiter.Ignore(); // avoid the collision to continue since this frame LevelManager.Instance.loseGame(true); // force die animation } // Returning false from a begin callback means to ignore the collision response for these two colliding shapes // until they separate. Also for current frame. Ignore() does the same but next fixed step. return(true); }
protected bool ChipmunkPreSolve_player_oneway(ChipmunkArbiter arbiter) { // If we're pressing the down arrow key. if (Input.GetAxis("Vertical") < -0.5f) { // Fall through the floor arbiter.Ignore(); return(false); } if (arbiter.GetNormal(0).y > -0.7f) { arbiter.Ignore(); return(false); } return(true); }
protected bool ChipmunkPreSolve_ball_oneway(ChipmunkArbiter arbiter) { if (arbiter.GetNormal(0).y > -0.7f) { arbiter.Ignore(); return(false); } return(true); }
public static bool beginCollisionWithPlayer(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; arbiter.GetShapes(out shape1, out shape2); Ghost ghost = shape1.GetComponent <Ghost>(); ghost.stop(); // kills player arbiter.Ignore(); // avoid the collision to continue since this frame LevelManager.Instance.loseGame(true); // force die animation // Returning false from a begin callback means to ignore the collision response for these two colliding shapes // until they separate. Also for current frame. Ignore() does the same but next frame. return(false); }