it's very likely that I'm missing something, but I can't find any good way to resolve my collisions using Hardon Collider. The collision detection part works like a charm, but I don't get how I'm supposed to "connect" the colliding shapes to my actual in-game entities in order to resolve collisions between let's say different types of objects. Here's an example:
Code: Select all
-- main.lua -- Pseudo code btw local HC = require("HC") local Platform = Platform() -- type = "Platform" local Player = Player() -- type = "Player" local Enemy = Enemy() -- type = "Enemy" function love.load() -- add shapes to my entities Platform:addShape(HC.rectangle(...)) Player:addShape(HC.rectangle(...)) Enemy:addShape(HC.rectangle(...)) end function love.update(dt) -- update entities Platform:update(dt) Player:update(dt) Enemy:update(dt) end function love.draw() -- draw entities Platform:draw() Player:draw() Enemy:draw() end ... -- Player.lua local HC = require("HC") ... function Player:updateCollisions(dt) -- check for collisions for shape, delta in pairs(HC.collisions(self.shape)) do -- now I need to know what type the other entity is to resolve the collision -- because the player ie should respond differently to platforms (ie "land on") then to enemies (ie "add damage") if otherEntityType = "Platform" then -- Do stuff elseif otherEntityType = "Enemy" then -- do other stuff end end end ...
How would you guys solve this problem? Thanks in advance.