void doRightWallJump() { PlayerActionEvent newEvent = new PlayerActionEvent(this, PlayerAction.RightWallJump); newEvent.call(); if (newEvent.isCancelled) { return; } player.velocity = Vector2.zero; player.AddForce((Vector2.up + Vector2.left) * behaviour.wallJumpImpuls, ForceMode2D.Impulse); }
void doSlide(Vector2 boost) { PlayerActionEvent newEvent = new PlayerActionEvent(this, PlayerAction.Slide); newEvent.call(); if (newEvent.isCancelled) { return; } player.AddForce(boost * behaviour.slidingImpuls, ForceMode2D.Impulse); // push player once isSliding = true; }
// public bool touchingJumpable (Collider2D trigger, ContactFilter2D filter) { // Collider2D[] colliders = new Collider2D[4]; // smaller array = better performance but more detection mistakes // trigger.OverlapCollider (filter, colliders); // foreach (Collider2D collider in colliders) { // if (!collider) continue; // Solid solid = collider.gameObject.GetComponent<Solid> (); // if (!solid || solid.isJumpable) return true; // } // return false; // } void doJump() { PlayerActionEvent newEvent = new PlayerActionEvent(this, PlayerAction.Jump); newEvent.call(); if (newEvent.isCancelled) { return; } player.velocity = new Vector2(player.velocity.x, 0); player.AddForce(Vector2.up * behaviour.jumpImpuls, ForceMode2D.Impulse); }