// ManualUpdate is called once per frame by CharacterBody override public void ManualUpdate () { //Check if we hit a wall, turn around if we do if (body.CheckDirectionCollision (currentDirection)) { currentDirection = (currentDirection == CharacterBody.Direction.LEFT) ? CharacterBody.Direction.RIGHT : CharacterBody.Direction.LEFT; } //Walk in current direction if (currentDirection == CharacterBody.Direction.LEFT) body.MoveLeft (); else if (currentDirection == CharacterBody.Direction.RIGHT) body.MoveRight (); }
// ManualUpdate is called once per frame by CharacterBody override public void ManualUpdate() { //Check if we hit a wall, turn around if we do if (body.CheckDirectionCollision(currentDirection)) { currentDirection = (currentDirection == CharacterBody.Direction.LEFT) ? CharacterBody.Direction.RIGHT : CharacterBody.Direction.LEFT; } //Walk in current direction if (currentDirection == CharacterBody.Direction.LEFT) { body.MoveLeft(); } else if (currentDirection == CharacterBody.Direction.RIGHT) { body.MoveRight(); } }
public bool directionColliding(CharacterBody.Direction dir) { if (dir == CharacterBody.Direction.LEFT) { return(LeftIsColliding()); } else if (dir == CharacterBody.Direction.RIGHT) { return(RightIsColliding()); } else if (dir == CharacterBody.Direction.UP) { return(TopIsColliding()); } else { return(BotIsColliding()); } }