how to create collision between two entities.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
how to create collision between two entities.
I know this has been asked a million times but all the treads I look at seem to not work. I have a player and an enemy and I want them to collide. At the moment they are both just rectangles.
-
- Prole
- Posts: 2
- Joined: Mon Aug 10, 2015 12:36 pm
Re: how to create collision between two entities.
https://github.com/kikito/bump.lua is probably what you're looking for. It's really easy to set up, has a great tutorial and is incredibly fast.
Re: how to create collision between two entities.
Here is a simple collision detection function:
Link to Love2D wiki: http://love2d.org/wiki/BoundingBox.lua
Code: Select all
-- Collision detection function.
-- Returns true if two boxes overlap, false if they don't
-- x1,y1 are the left-top coords of the first box, while w1,h1 are its width and height
-- x2,y2,w2 & h2 are the same, but for the second box
function CheckCollision(x1,y1,w1,h1, x2,y2,w2,h2)
return x1 < x2+w2 and
x2 < x1+w1 and
y1 < y2+h2 and
y2 < y1+h1
end
Who is online
Users browsing this forum: No registered users and 9 guests