Platypus - Defold platformer engine


#1

@britzl

I noticed you updated Platypus over the past couple of days! If anyone is creating a platformer without this extension I strongly recommend you take a look at it, it’s brill!

https://github.com/britzl/platypus

I have a few questions:

  1. The new seperation option: Using platypus.SEPARATION_RAYS completely fixes an issue I had with slow moving objects colliding with individual tiles and getting stuck. Is this sticking effect the reason it was introduced?

  2. The subsequent reintroduction of a platypus.SEPARATION_SHAPES option. Was this simply for completion or did you notice a use scenario where this option works better than with rays?

  3. instance.up(velocity) and instance.down(velocity): Could you please give a usage example for these. Whenever I use them they immediately get cancelled by gravity. I got round this by adding a platypus.set_gravity(gravity) function to platypus.lua. Using this to set gravity to 0 when the player has ladder contact for example and up and down work but I could be missing something completely obvious.

	-- Set or change gravity after initialization
	-- @param gravity
	function platypus.set_gravity(gravity)
		platypus.gravity = gravity
	end

Other than that thanks a lot for the superb library!


#2

Hey! Glad you found the lib! I haven’t announced it and I snuck it into the Asset Portal. I’m not sure where the lib is going but I realised that platformer games are pretty hard to make and I found myself copying code from project to project.

Regarding collision separation: I used to only use collision shapes and separate collisions that way. It usually works well, but sometimes the player gets stuck. This happens when you use a box shape. The solution is to use spheres instead. I typically use several small spheres, perhaps one bottom left and one bottom right and then either a central larger sphere for the body or a box shape that doesn’t touch the ground.

What I don’t like about collision shapes is that it sometimes is hard to decide ground vs wall contact. That’s why I’m using ray casts as well.

And then I decided to try to only use ray casts for collision separation. It usually works really well, but I’ve found that when you’re on a vertically moving platform it sometimes flickers between ground contact and falling. This seems to work better with normal collision shapes. The length of the rays also has impact and since I’m currently working on a LOWREZJAM game I find ray casts to work less good.

I’ll add ladders to the example project to show how that could work. I have ladders set up and working in another project. Can’t remember the details now.


#3

Please let me know if you have any feature suggestions for the lib!


#4

Not sure how many of these are in scope of your lib but some of these would at least be useful to show in examples

  • Hang on edge of platforms / wall nooks / pegs
  • run
  • double jump (or as many extra jumps)
  • downward slam
  • upward super jump (rook)
  • spiderman style rope swing / hook shot swing
  • look up / down when holding up or down move camera up or down
  • couch to avoid bullets aimed and player head
  • crawl to crawl under short areas
  • slide to slide under short areas
  • wall hold slide down
  • jump down from one way platformers by holding down and jump
  • horizontal dash
  • dash to break breakables
  • jetpack
  • ropes
  • swim
  • free fly
  • different gravity zones
  • swap vertical gravity
  • portals
  • doors
  • pushable blocks
  • camera shake (want to use noise so it’s smooth I have examples somewhere…)
  • micro freeze frame when taking damage / doing damage
  • basic enemy AI following player and is willing to fall off platforms / will try to jump to nearby platforms if it can / free fly ai that chases player / ai which walks between paths
  • slopes (you need a custom pill shape for this to work right)
  • parallax systems for background layers
  • jumping bounce pads
  • windy areas
  • icy floors that are slippery
  • keys / doors / switches
  • collectibles

#5

Would be nice to see this in a new jacket since the Platformer Creation Kit from the Asset store is a little bit outdated.


#6

@britzl

Thanks for the additional info re the collision seperation types and issues etc. Also the spheres collision shapes. This is good info and considering there’s so many caveats with this particular task info is key.

I was also using too much code duplication between players / enemies / objects etc and was at the point of enquiring for collaboration on the forums to create a definitive platformer extension. Then I found Platypus which solved most of my issues off the bat so i think this should be it! :wink:

In fact I had so few problems with it it was only when I slowed a particular enemy down and the sticking issue raised it’s ugly head I had another look. Then literally the day after you’d done the updates I could use to fix. Which was nice. :smile:

@Pkeod @britzl

Whoa! It’s only when you see a list like this you realize how many actions and scenarios are in modern platformers.

Going through the list I think a lot of these could be solved in a main player script if more of the Platypus config options are exposed and changable on the fly.

For example:

  1. Hang on to edge of platforms could work if we detect if we were touching a colision object in the player script and set gravity to zero in Platypus

  2. Ropes, I already did this by stopping the Platypus update in the player script if the player was touching a rope and then using the player script to position the swing, then restaring the Platypus update again when jumping off

  3. Free fly / jetpack again, changing gravity on the fly and using the Platypus move up / move down funcitons

So for me the feature suggestions would be:

  1. Expose the config options so they’re changable in real time (edit: probably could also do this by nil’ing the existing instance and creating a new one but on the fly changes would be easier)

  2. Add the ability to force a jump if needed, currently you need to be touching the ground or wall or doing a double jumps. Jumping off a rope currently is not possible without modifying platypus.jump() with an extra forced jump arg.

All Pkeod’s suggestions could then be doable in the player script then I think? I also agree, this is such a pain in the jacksie to get right examples are essential!


#7

Thank you for the suggestions! Created two issues to track these:



#8

Thank you for the list! As @approbo.games says, many can be built on top of the existing features in a player script. Some might be worth including in the core lib. I’ve added the entire list for now to an issue and I’ll go through it later.