Code Monkey home page Code Monkey logo

2d-platformer-hunter's Introduction

image

2D Platformer Hunter

Implementation of a raycast-based 2D platformer controller in Unity.
Extended from Sebastian Lague's Creating a 2D Platformer series with more customizable options and better modularization.

Table of Contents
  1. Description
  2. Installation
  3. Design
  4. Features
  5. Misc Notes
  6. Credits
  7. License

Description

Installation

Design

The code structure is based on a Input-Controller-Motor model. Each controller consists of three individual components: Input, Controller and Motor.

Each module can be replaced with user-customized module to achieve various gameplay mechanics.

  • The Input serves as the brain of the controller. The brain can be a preprogrammed AI system or be player-controlled. Input modules also support waypoint navigation for moving platforms.
  • The Controller represents the body of the controller. The body represents the actions a given character can perform. This includes regular movement, jumping, double-jumping, and dashing.
  • The Motor controls the physics acting on the controller. For example, a motor for a given character can collide with obstacles in a level. A motor for a platform or other level object can carry other motors and transforms.

Other behaviours that do not belong to these three modules should instead be implemented in a different external components and set to listen to events sent out by one of these three main modules.

For instance, a sprite animation controller that swaps sprites when a character performs a jump should be set to listen to the OnJump event of the CharacterController object.

Features

Jumping

  • Jump Input Buffering
    • An inputted jump will be held and buffered for a period of time until the character has an actionable jump again, to improve responsivenes.
  • Coyote Time
    • Also known colloquially as "Grace Period Jumping". If a jump input is registered very shortly after a player character moves off a jumpable surface, the jump still occurs despite technically being mid-air.
  • Variable Jump Height depending on held button.
  • Wall Jump
  • Air Jump

Climbing

  • Editable climbing area
    • Supports climbing on designated areas such as ladders and ropes. Climbing and non-climbing areas are distinguished by an area trigger. The controller will smoothly interpolate its position from the area trigger onto the climbable area.
  • Ledge Grabbing
  • Wall Climbing
    • Configurable behavior depending on whether you prefer your controller to slide down walls or climb up them.

Other

  • Dash modules that can be applied to controllers to alter dashing behavior.
  • Smooth movement on slopes
  • One-Way Platform component that horizontally translates a platform in one direction.
  • Moving Platform component that includes a node editor for waypoint editing.

Misc Notes

  • The raycaster collision layer must be on different layer than the GameObject, to ensure gravity scaling and prevent unintended behavior.

Credits

License

  • Licensed under the MIT License, meaning it is freely editable as long as the original copyright notice and disclaimers are included.

2d-platformer-hunter's People

Contributors

ernestoamujica avatar ta-david-yu avatar team-on avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

2d-platformer-hunter's Issues

Motor Collider

Not really an issue. The motor works pretty great. Is there any way to out-of-box access the collider that is around the player? I want to adjust it for ducking. I have an abstract class called Behavior and Duck is a behavior component. When my character ducks I need to access the center of the box and the collider itself to resize it. I will need to access the motion speed as well to stop him when he attacks and speed him up when running. Awesome addition to 2D controllers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.