Geek Culture
Published in

Geek Culture

Death by Falling — No Dead Zones, just Impact

Objective: make the player die after a long fall with an impact on a platform

I thought that also a drastic impact on a platform should be lethal. This means that, apart from the use of dead zones, we need to implement a feature that would recognize such impacts — after a long fall — and make the player die.

Since we have a working death logic, we should try and use it also in this scenario.

One way of detecting a lethal fall is by measuring y-velocity: if it is lower than a given negative value (so big in absolute value), there will be no chance of surviving! As a start, I chose -50.

We need to check for this value while the character is falling. Fortunately, we know that when this happens, a state behaviour is already working in the falling script and we can put there our logic. Basically, on update we check the y-velocity when the player is finally grounded: if it is over the threshold, we call the death logic which will take care of everything concerning death, otherwise, we land as usual.

As simple as it gets!

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

PERPETUAL tri-weekly burning CORD & VACC (permanently reduce supply), & tri-weekly lottery to win…

Initial impression of Pinephone Pro Explorer Edition

Create a Simple Web API Project with ASP .NET Core and Entity Framework to perform CRUD operations

The easiest way to learn Excel Macros interactively

How to update the IP Address for a Record in Route53 with assuming role via AWS CLI

RosePad Update #2

Learning programming is DIFFICULT

Taming Google Container Builder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Daniele Quero, PhD

Daniele Quero, PhD

A professional developer with passion for game developing and skill-growing. A former Nuclear Physics Researcher who changed his life to pursue his dreams

More from Medium

Aggressive Enemy Behaviour after a Hit

Journal 142 — Unity Project Development, 2.5D Shooter

Switch Statements to the Rescue

Audio effects for Enemies