Giter Site home page Giter Site logo

city's Introduction

PlatformerController2D

A 2D platformer class for godot.

Changelog

Version 2.0

  • Updated to Godot 4.0

    • Removed set and get functions in favour of properties
  • Can now have negative jump height, which will reverse gravity

  • Gravity is now positive when pointing down, and negative when pointing up

  • Added 'jumped' and 'hit_ground' signals

  • Split the large _physics_process function into multiple functions

Version 1.0.1

  • Updated to Godot 3.4
  • Fixed division by zero error when changing min jump height
  • Other minor fixes

Installation

  1. Add platformer_controller.gd to your project
  2. Type extends PlatformerController2D to the top of your script
  3. Add these input mappings in your project settings (or you can change the input variables in the inspector)
    • "move_left"
    • "move_right"
    • "jump"

Features

  • Double jump
  • Coyote time
  • Jump buffer
  • Hold jump to go higher
  • Defining jump height and duration (as opposed to setting gravity and jump velocity)
  • Assymetrical jumps (falling faster than rising)

Customization / Export variables

Here are the values that you can change in the inspector:

max_jump_height

The max jump height in pixels. You reach this when you hold down jump.

Min Jump Height

The minimum jump height (tapping jump).

Double Jump Height

The height of your jump in the air (i.e. double jump, triple jump etc.).

Jump Duration

How long it takes to get to the peak of the jump (in seconds).

Falling Gravity Multiplier

Multiplies the gravity by this while falling.

Max Jump Amount

How many times you can jump before hitting the ground. Set this to 2 for a double jump.

Max Acceleration

How much you accelerate when you hold left or right (in pixels/sec^2).

Friction

The higher this number, the more friction is on your character.

Can Hold Jump

If this is off, you have to press jump down every time you land. If its on you can keep it held.

Coyote Time

You can still jump this many seconds after falling off a ledge.

Jump Buffer

Pressing jump this many seconds before hitting the ground will still make you jump.
Note: This is only needed when can_hold_jump is off.

Input Variables

input_left
input_right
input_jump
Set these to the names of your actions in the Input Map

city's People

Contributors

bdog12 avatar

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.