Problem with tile collision

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
AdrianN
Prole
Posts: 10
Joined: Wed Mar 28, 2018 5:13 pm

Problem with tile collision

Post by AdrianN » Sat Jun 16, 2018 12:27 am

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

User avatar
Pospos
Citizen
Posts: 68
Joined: Sun Jun 18, 2017 11:10 am
Location: Agadir

Re: Problem with tile collision

Post by Pospos » Sat Jun 16, 2018 2:24 pm

Post the love file using attachements.
ⵜⴰⵎⴰⵣⵉⵖⵜ(https://en.wikipedia.org/wiki/Berbers)

User avatar
AdrianN
Prole
Posts: 10
Joined: Wed Mar 28, 2018 5:13 pm

Re: Problem with tile collision

Post by AdrianN » Sat Jun 16, 2018 5:27 pm

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
Attachments
ma_nocollidable.love
(1.96 MiB) Downloaded 22 times
ma.love
(1.96 MiB) Downloaded 22 times

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests