Page 1 of 1

Problem with tile collision

Posted: Sat Jun 16, 2018 12:27 am
by AdrianN
Hi all, I have a problem...
I tried to make a platformer game to learn, like http://osmstudios.com/tutorials/love2d- ... ing-levels
and and that works, but only for the main character, the enemies is another history.
Enemies no step the ground, they just move in x axis (velocity + -), I tried to make like the player, the problem is where they collision, they can´t move.
Image

Code: Select all

function espadachin:init()
.... 
	Entity.init(self, world, x, y, self.imgx[self.it],self.imgy[self.it])
	self.world:add(self, self:getRect())
end

function espadachin:collisionFilter(other)
  local x, y, w, h = self.world:getRect(other)
  local espadachinBottom = self.y + self.h
  local otherBottom = y + h
    return 'slide'
end

function espadachin:update(dt)
....
self.x, self.y, collisions, len = self.world:move(self, self.x, self.y, self.collisionFilter)

	  for i, coll in ipairs(collisions) do
	    if coll.normal.y < 0 then
	      self.isGrounded = true
	    else
	      self.isGrounded= false
	    end
	  end


I thinking to use love.physics and take a dynamic body all the map, but I would need get all tilelayer with any function, like.

Code: Select all

	for k, object in pairs(map.objects) do
	end
Someone can explain me any solution, please?

I used STI library and bump library

Re: Problem with tile collision

Posted: Sat Jun 16, 2018 2:24 pm
by Pospos
Post the love file using attachements.

Re: Problem with tile collision

Posted: Sat Jun 16, 2018 5:27 pm
by AdrianN
Pospos wrote: Sat Jun 16, 2018 2:24 pm Post the love file using attachements.
Sorry, here's the love file (ma_nocollidable.love):

Edit: I added the same player collision filter in babas.lua(slime), but I need to babas pass through player. (ma.love)
Result with collision filter:
Image