Collision not working

only on the player object. should the borders also be highlighted since they are in a collision group?

For some reason, the tiles don’t have a highlighted border in the tileset indicating the collision group

image

Have you followed the instructions on how to add collision shapes and assigned them to individual tiles?

you left click on the tile you want to add to the group while having that group selected, correct?

is that correct?

Yes, that is correct. But there is currently a bug in the editor preventing the tiles from showing which group they belong to:

I think it may be because I imported the tilemap from Tiled, b/c the one I made prior to that using the defold editor works fine

I am sorry, but do you know what could be causing this?
The -y velocity is for a different loaded collection

The player collides with the tile collision group but only after it has already sunk into the border.
The top of the screen has the opposite issue where the player never reaches the border tile.
And for some reason the player collides with the sides of the tiles fine

How are you resolving the collisions? What does it look like when you enable Physics Debug in game.project? Are the collision shapes where you expect them to be?

side collision
image

Bottom collision
image

Top Collision
image

The collision shapes should be on the spotted black - though that is difficult to see since in the physics debug screen everything is a shade of green.

This is how I am resolving collisions

   local function handleLevelCollisions(self, normal, distance)
	if normal == nil then
		print("Error: normal is nil")
		return
	end

	print("Collision Normal:", normal)
	print("Collision Distance:", distance)

	-- Get the info needed to move out of collision. We might
	-- get several contact points back and have to calculate
	-- how to move out of all of them by accumulating a
	-- correction vector for this frame:
	if distance > 0 then
		-- First, project the accumulated correction onto
		-- the penetration vector
		local proj = vmath.project(self.correction, normal * distance)
		print("Projection:", proj)
		if proj < 1 then
			-- Only care for projections that does not overshoot.
			local comp = (distance - distance * proj) * normal
			-- Apply compensation
			print("Compensation:", comp)
			go.set_position(go.get_position() + comp)
			-- Accumulate correction done
			self.correction = self.correction + comp
			print("Accumulated Correction:", self.correction)
		end
	end
end

I copied the code in the guide, and I added the print statements while I was debugging

I can’t spot anything obvious. You reset the correction in update()?

If you can’t solve this on your own please share a minimal project here as a zip file.

yes, it is resetting in update()

scaling down the map to 1x1 seems to have fixed it.

do you know what this is caused by?

There are a lot of confusing things about the project:

  • You have duplicates of all script files. There is one set of files in Scripts/ and one set of identical files in main/Scripts
  • You have two instances of PlayerMap.go used at the same time:

  • There is a Player.script with gravity that seems to be running in the background while the menu is shown. Why?
  • The PlayerMap.script is calling camera.acquire_focus("operatorMap#cameramap") but the game object is named OperatorMap with an upper case O.
  • You calll msg.post("@render", "use_camera_projection") but it should be “@render:”
  • You have a very strange scale on the map:

The problem is that weird scale you have on the map. It will make the physics shapes misalign with the graphics:

If you wish to zoom, then modify the zoom of the camera instead!

I strongly encourage you to start from an empty project and gradually build up from what you have in the current project. The project you have now is quite messy.

the duplicate script files are from when I was copying the files into a new project, I got rid of most of the stuff not privy to the issue. The player go is for a platforming section, I figured the messaging would be a bit easier if they were in the main collection. The camera was just human error, though for some reason it was still working, just poorly.