Bad 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
baconhawka7x
Party member
Posts: 491
Joined: Mon Nov 21, 2011 7:05 am
Location: Oregon, USA
Contact:

Bad Collision

Post by baconhawka7x »

i was wondering if someone could help me find the problem with my collision. Mainly The first test(You'll see where I commented).

for some reason when you run along the top of the tiles. If you are lagging enough (Which still happens, because I don't know why). You hit these things that act like speedbumps. It's at the end or beggining of tile and you just suddenly stop, and again, it only happens when your frame rate is low enough.

Here's my collision detection/resolution.

Code: Select all

if v.x < player.x + renderdistance and
	v.x > player.x - renderdistance then--So it doesn't test with EVERY SINGLE tile.
			if player.y + player.height > v.y and -- This is the first test, it is testing if the player is on top of a tile, of course, the problem probably isnt coming from this, but I thought I should point it out.
			player.y + player.height < v.y + (v.height / 2) and
			player.x + player.width > v.x + 1 and
			player.x < v.x + v.width - 1 then
				player.y = v.y - player.height
				player.yvel = 0
				player.jumping = false
				player.grounded = true
			end
			if player.x + player.width > v.x and --if the player is running into the left side of a tile
			player.x < v.x + (v.width / 2) and
			player.y + player.height > v.y + 1 and
			player.y < v.y + v.height - 1 then
				player.x = v.x - player.width
				player.xvel = 0
			end
			if player.x < v.x + v.width and --if the player is running into the right side of a tile
			player.x > v.x + (v.width / 2) and
			player.y + player.height > v.y + 1 and
			player.y < v.y + v.height - 1 then
				player.x = v.x + v.width
				player.xvel = 0
			end
			if player.y < v.y + v.height and -- If the player is hitting the bottom of a tile(kinda half assed because the player doesn't run into the bottom of tiles ever.
			player.y > v.y + (v.height / 2) and
			player.x + player.width > v.x + 1 and
			player.x < v.x + v.width - 1 then
				player.y = v.y + v.height
				player.yvel = 0
			end
		end
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 82 guests