True Tile Collision

Cool, got it!

1 Like

Got to say I programmed everything like I’d do that in C style language, so I’m wondering if doing that with tables makes it more efficient instead of manipulating object instances variables?

Can you show an example of what you mean?

2 Likes

I don’t really have imagination for good example that have good use of LUA, but what I do is pass self to functions to create variables inside instance or manipulate them:

function h_move(inst)
	local hin = inst.xinput														--xinput set in get_xinput()
	local hsp = inst.spd.x
	if hin ~= 0 then															--Move
		hsp = hsp + hin * inst.ACC
		hsp = clamp(hsp, -inst.MAX, inst.MAX)
	else																		--deaccelerate
		hsp = approach(hsp, 0, inst.DCC)										--(value, goal, ammount)
	end
	inst.spd.x = hsp
end

Yeah, that sounds good.

1 Like

I’m thinking to rename these flags to have most convenient names. Any suggestions?

Been a bit busy but kept tinkering and now up to last struggle to reach the last mile to the finish.
I have introduced platformer essential thing - moving platforms, but I have a small problem with collision.
After that, I’m wrapping up building blocks for top-down movement and platformer without slope collision.

Playable demo on itch, example project & lua module on github are updated.
Now there’s 3x examples (block platformer, platformer using slopes and top down movement).

2 Likes

So right before creating the Asset portal page, I created brief READ ME to explain how easy it is to add the TTC to the game.

Hey this is really cool!
Is this faster than just using a few collision shapes and physics? I usually use 2 collision shapes for the player 1 for the feet and 2 for the head so if I’m crouching I can disable the head collision shape.

This is more like retro physics, super fast to set up for that - think NES games and not far from that.
Right now there’s nothing to work for automatic crouching, but if you have some knowledge and willing to check code it’s not that hard to create such behavior. At the moment you can use set_hitbox to set different hit box size when player wants to duck.

Looks good!

If I may make 2 suggestions;

  1. move tile types for set tiles to its own file and return so these can be easily modified.
  2. provide half tile collision (horizontal and vertical)
  1. I’m weak at using Lua and generally with Defold, set_tiles just change values in lua module local variables that hold ID of tilesource to look for a collision. Sounds like you are able to do it yourself.
  2. It’s doable of course, but change the whole collision checking fundamentally. At that point, it’s better to use smaller tile size.
    THIS is the type of games I had in mind when I developed the collision system.

UPDATE:

  1. Added dashing ability (included in the example project)
  2. Changed state variable names to the more conventional format
--STATES	
inst.is_grounded	  	= false
inst.is_jumping	  		= false
inst.is_dashing	  		= false						
inst.is_wallsliding  	= false
inst.is_on_ledge	  	= false
inst.is_hurt		  	= false

I’ll update playable demo a bit later.

UPDATE:
1. Added hurt state - kickback and disabled player input on physics. Call with got_hurt(self, xspeed, yspeed);
2. In the example, there are added tips for controls.

As one of the future feature, I’m thinking to add crouching, but that will work if the player is taller than one tile height.

1 Like

Hey @NeZvers, is this library still maintained? I’m considering it for sloped platforms.

Ps. Does it support sloped ceilings?

2 Likes

It works without any problems with tile based slopes (45 and ~30 degree) :wink:

2 Likes

45 and 22.5 :wink:
But you can give it a test in this Demo.

5 Likes

Hi,
what are the advantages of using this collision system in place of the original integrated using colliders?
I’m just trying to figure out if this library is right for me.

I am not using it nowadays and I’m not sure it is working, but I would say it could be, for example, great when you have a lot of changes in the level during the game, but your level is still tile based. Imagine a game like Broforce, where you can destroy almost everything, but characters can still walk and jump over the remnants of the level.

or… Bore Blasters! which is actually made in Defold by @Alex_8BitSkull which looks like definitely be handled by tile maps, but I don’t know for sure :grin: and most probably not TTC (as it’s focused on Platformer games)