Zombie Collision
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Zombie Collision
Sorry for all the constant post but i tried adding colliosion to the zombies where when its hits another zombie it doesnt just stack on top of each other. and when it hits the player it wouldnt just stack underneath him. noting crashes or anything it just doesnt work. any help would be appreciated. i attached a .zip and .love file of the game
- Attachments
-
- Platformer.zip
- Zip
- (36.89 KiB) Downloaded 92 times
-
- Platformer.love
- Love
- (36.89 KiB) Downloaded 107 times
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Zombie Collision
How are you doing the collision check between the player and the zombies ?
EDIT: The zombies stack on each other
EDIT: The zombies stack on each other
Re: Zombie Collision
The left side of the player to the right side of the zombie. pw is playerWidth.
Code: Select all
for i,zz in ipairs(zombie) do
if zz.x == player.x + pw then
zz.x = zz.x
end
end
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Zombie Collision
Your code is wrong if you want to use it for collision detection.
Basic rectangle to rectangle collision detection, zz.h is zombie's height, zz.w is zombie's width, ph is player's height:
Basic rectangle to rectangle collision detection, zz.h is zombie's height, zz.w is zombie's width, ph is player's height:
Code: Select all
for i,zz in ipairs(zombie) do
if zz.x < player.x + pw and player.x < zz.x + zz.w and zz.y < player.y + ph and zz.y+zz.h > player.x then --player and zombie "i" are colliding
--revert back zombie to the last none safe position
end
end
Who is online
Users browsing this forum: Google [Bot], Semrush [Bot] and 8 guests