25 views

Uploaded by stunt102_thegame

Make a platformer

- Kinematics Problems Set3 Solutions 2jygpyj
- Rj Motion
- What Causes Time
- Motion In One Dimension Question
- New Microsoft Office Word Document
- 01l-tmd-01.pdf
- Moving Man Acc Lab
- Physics Sample QP Half Yearly Exam
- MIT8 01SC Problems07 Soln
- IRT Transcript 0100 Holy Grail of Physics
- Lesson 01 to 08 Review[1]
- issac newton
- 7. Chapter III (Satellite) [ {Pg. 32-36}
- mech syllabi
- Grade 12 Physics Exam Questions and Answers
- megamanx8
- Chapter 06
- Chap 8
- Kinema Tic Eq Ns
- 3rd Secondary 1

You are on page 1of 4

http://www.error454.com/2013/10/23/platformer-physics-101-and-the-3-fundamental-equations-of-platformers/ 1/4

By Zachary Burke | October 23, 2013

Platformer Physics 101 and The 3 Fundamental

Equations of Platformers

There are tons of tutorials out there on doing platformer physics andimplementing various types of

platformers. What there seems to be lacking is a tutorial on how to choose good values for your

platformer physics.

This article will present some core physics equations in a new light! I will even be so bold as to christen

these equations as The Fundamental Equations of Platformers. The sample code here is presented in

LUA and for my prototyping I am using the ShiVa 3D game engine.

When designing physics for a platformer, the 2 fundamental values required are:

1. The strength of gravity

2. The initial velocity of a jump

With these values, were able to use the the kinematic equations to make a character jump and

eventually touch the ground again.

Basic Physics

3/22/2014 Please see comment by Ricky below. These simple equations are the calculus versions

broken down for simplicity, not the kinematic equations.

As a refresher, the 2 basic equations well use are:

This would be a typical implementation.

1

2

-- Set Y velocity to the jump velocity

this.nVelocityY( this.kVelocityJump )

1 -- Apply gravity every frame

Handle the jump Lua

Apply Gravity Lua

9/25/2014 Platformer Physics 101 and The 3 Fundamental Equations of Platformers | error 454

http://www.error454.com/2013/10/23/platformer-physics-101-and-the-3-fundamental-equations-of-platformers/ 2/4

This code is at the heart of platformer physics, but when it comes down to it, these equations alone

kind of suck at being useful. Picking random values isnt the best way to get a good feeling platformer.

Lets look at a method that will help get you started with initial physics values.

The Fundamental Equations of Platformers

What makes more sense is to calculate gravity and initial jump velocity by picking 2 simple properties of

the universe:

1. Max jump height

2. Time to reach max height

Which leads us to the first two fundamental equations:

So what weve defined above are:

gravity as a function of the time to reach the top of the jump andmaximum jump height.

initial jump velocity as a function of gravity and maximum jump height

See the Derivations

Early Jump Termination

Edited 3/5/2014

As reader Chue points out, the equations below dont work unless gravity is negative. This is true

and was an oversight on my part. You could redefine the above equation for gravity and just tack

a negative sign on it. This also means that the equation for jump velocity is going to yield an

imaginary number (square root of a negative number), you can just throw that imaginary part

away. Ive updated the equations below to show that gravity is being plugged in as a negative

2

3

4

5

6

7

8

local dt = application.getLastFrameTime( )

local newVelocityY = this.nVelocityY( ) - this.kGravity

local distanceToMoveY = newVelocityY * dt

-- Assuming collision detection was ok, move the actor

object.translate( this.getObject( ), 0, distanceToMoveY

this.nVelocityY( newVelocityY )

9/25/2014 Platformer Physics 101 and The 3 Fundamental Equations of Platformers | error 454

http://www.error454.com/2013/10/23/platformer-physics-101-and-the-3-fundamental-equations-of-platformers/ 3/4

number.

The end numbers havent changed, I just failed to show my work. The spreadsheet at the end of

the article was not affected.

There are a few ways to do early jump termination but I am going to propose a method that is based on

a single parameter, minimum desired jump height. The idea is to calculate the downward velocity

required to achieve this minimum height. I now present the 3rd fundamental platformer equation

(which is a well known kinematic equation):

To use this, we choose our minimum jump height of 1 unit and we arrive at:

So then in code, when a player releases the jump key, youd do the following:

The one caveat with this method is that, depending on your world, you may set a minimum jump height

that is impossible for a human to hit. Because obviously we have limitations, like not being able to press

and release a key much faster than 200 milliseconds. So, as a friendly check, we can calculate the last

possible second that a jump can be terminated using this equation:

Demo

To prove out the equations and method, I did my best to recreate the physics from Mario 1 inside the

ShiVa 3D game engine. Based on my reverse engineering efforts (see details below) I arrived at the

following values:

Max Jump Height = 4 units

Time to reach max height = 0.44 seconds

Minimum jump height = 1 unit

1

2

3

4

if( this.nVelocityY ( ) > 0 ) then

-- Set velocity to whatever is smaller, termination velocity or current velocity

this.nVelocityY ( math.min ( this.kJumpVelocityTermination

end

Terminating a jump Lua

9/25/2014 Platformer Physics 101 and The 3 Fundamental Equations of Platformers | error 454

http://www.error454.com/2013/10/23/platformer-physics-101-and-the-3-fundamental-equations-of-platformers/ 4/4

So plugging these into equations 1, 2 and 3 we get

Now see it in action, spacebar jumps.

- Kinematics Problems Set3 Solutions 2jygpyjUploaded bysam_roy124
- Rj MotionUploaded byMadhumika Thammali
- What Causes TimeUploaded byZvonko Ns
- Motion In One Dimension QuestionUploaded byabh_omega
- New Microsoft Office Word DocumentUploaded byRana Waqas
- 01l-tmd-01.pdfUploaded byandrea_ma_infinty
- Moving Man Acc LabUploaded byRishab Chawla
- Physics Sample QP Half Yearly ExamUploaded byroythomasc
- MIT8 01SC Problems07 SolnUploaded byJackie Peccadillo Lim
- IRT Transcript 0100 Holy Grail of PhysicsUploaded byJimm Newtron
- Lesson 01 to 08 Review[1]Uploaded byi5piriti
- issac newtonUploaded byapi-253599101
- 7. Chapter III (Satellite) [ {Pg. 32-36}Uploaded byramces paul benipayo
- mech syllabiUploaded bySudeb Sarkar
- Grade 12 Physics Exam Questions and AnswersUploaded byGinger
- megamanx8Uploaded byMichael Mikuru
- Chapter 06Uploaded byAmeet
- Chap 8Uploaded bymera_gyan
- Kinema Tic Eq NsUploaded byritchie_h
- 3rd Secondary 1Uploaded byRaghebBahiEdden
- 3.6 Moving CV example.pdfUploaded byStephen Buckey
- Physics+Cheat+SheetUploaded byjlvmrbd777
- MechanicsUploaded byLovnish Sharma
- Dynamics LectureUploaded byOblack
- 1.-JSTSE-2017-2018-Class-IX...Paper_.pdfUploaded byRoopam Taneja
- balance by drjeager hahahaha.docxUploaded byOraclElder spirit
- PhysicsUploaded byzachriggle
- Phys03 KinematicsUploaded bygijoe88
- Hydraulic Loading RatesUploaded byZul Imi
- Orbit Runge Kutt a 4Uploaded byPrakash Guragain

- Book Snippet Sine CosineUploaded bystunt102_thegame
- What is Big Data, and Who's Collecting ItUploaded bystunt102_thegame
- ARTICULO 1[1]Uploaded byLuz Amalia
- The Best Productivity Tricks You Can Learn From Rock StarsUploaded bystunt102_thegame
- Simple portable personal DIY book scanner.pdfUploaded bytelemaco44
- Solar Usb ChargerUploaded bystunt102_thegame
- Platformer Physics 101 and the 3 FundamentalUploaded bystunt102_thegame
- ThePomodoroTechnique_v1-3Uploaded byEugenia Tanase
- Bodyweight ExercisesUploaded bystunt102_thegame
- Beating ProcrastinationUploaded bystunt102_thegame
- Android Rooting GuideUploaded byrks70
- Five Best Google Reader AlternativesUploaded bystunt102_thegame
- 4 Week Meal PlanUploaded bystunt102_thegame
- Beating ProcrastinationUploaded bystunt102_thegame
- CareerGuide2012-dl.pdfUploaded byThiago Gomes
- Make a Neon Vector Shooter in jMonkeyEngine: Enemies and SoundsUploaded bystunt102_thegame
- Which Programming Language Should I Learn FirstUploaded bystunt102_thegame

- Chapter 6Uploaded byE Cos Lopez
- Most Important Resources for information in Juvenile JusticeUploaded byPuralika Mohanty
- Donuld Trup's Ethics_All Changes Accepted_Edited by LeshaUploaded byAlex Cher
- Sap Notes - FinalsUploaded byAnand Kumar
- The Dragon_s BibleUploaded byKinguAmdir-Ush
- Civpro Digest-rule 1 to Rule 3Uploaded byLuvLuv Dable
- Strategic LeadershipUploaded byAynul Bashar Amit
- Analog ,Digital and Power Electronics 100 Important Mcq Ww.allexamreview.comUploaded byattique
- Auditing VNX Control StationUploaded byBuggyne
- Swot AnalysisUploaded byronik_passwala
- What Influences Shopping Lesson PlanUploaded byShubham Tiwari
- Novena - St. ClareUploaded byMaiko Ichijo
- My DissertationUploaded byJoji Afridi
- UT Dallas Syllabus for aim3322.001 06s taught by Mary Beth Goodrich (goodrich)Uploaded byUT Dallas Provost's Technology Group
- ASTM G 190-06Uploaded byDayana Pozo
- Neuro Exam 2009Uploaded byAnne Gastrosis
- Quantitative Aptitude Shortcuts for Bank ExamUploaded bydibyenindus
- Do we want to extend life beyond death?Uploaded byYousuf M Islam
- rakesh sud - financeUploaded byapi-205246113
- 53065401 Banglalink Report Only for Survey QuestionsUploaded byehsanul1
- Modernisation TheoryUploaded bycharlsandroid01
- Dom Strategic PlanUploaded bymonir61
- wapooUploaded byapi-222890170
- Risk Management Best Practice Principles for FCMUploaded bynamhvu99
- The Role of SEBI in Corporate GovernanceUploaded byHarshit Sultania
- The Chinese Dream - a society under constructionUploaded byNeville Mars
- shabnam project.docxUploaded bySaim Hussain
- 003679528Uploaded byFizal Abdul
- Child rape.docxUploaded byLouise Arellano
- Additional Mathematics Project Work 2Uploaded byBlaire