So I'm trying to remake a flash game I made about a year ago but in love2D. I've got to the point where it's basically finished so I've decided to go and fix a few things.
The first thing was that I was using a normal AABB collision detection on rotated objects and sometimes bullets would go straight through zombies(I fixed this using a tutorial on 2D collision in roblox, go figure.)
The next thing was I wanted zombies to "push away" from eachother when they collided rather than merging into eachother.
The tutorial I used for rotated 2D collision also showed how to move objects away from eachother when they collided.
Each zombie is stored in a table, and then I loop through the tables to do stuff with them (like draw them, update etc. Zombies are created through another class)
But since they're in the same table, I'm not really sure how to go about making sure they're colliding with eachother.
for izom,zom in ipairs(main.zombies) do
zom:update(dt)
doesCollide,mtv = collide(zom,zom)
if collide(zom,zom) then
zom.Position = zom.Position + Vector2.new(mtv.x, mtv.y);;
end
end
I tried that, but it doesn't work.
How can I fix this?
for i=2,#main.zombies do for j=1,i-1 do stuff with zombie[i] and zombie[j] end end
– Dimitry