Help with some Collision Errors

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
BulbaMander
Citizen
Posts: 65
Joined: Sat Dec 15, 2012 7:00 pm

Help with some Collision Errors

Post by BulbaMander »

Hello there! I am having quite a bit of trouble on some collision detection. I am using Kirito's bump.lua, here is where I THINK the problem is.

Code: Select all


--from main.lua, bump's main callback
function bump.collision(item1,item2,dx,dy)
	item1:shouldCollide(item2,dx,dy)
	item2:shouldCollide(item1,dx,dy)
end

--from player.lua, the Player:shouldCollide function for bump.collision
function Player:shouldCollide(other,dx,dy)
	if dx~=0 then self.x=self.x+dx end 
	if dy~=0 then self.y=self.y+dy end 
	print(dx,dy)
end

What is happening is that the player is getting stuck in on of the blocks and I am not sure why, or how. I cant't even get it to bug out consistently, sometimes it works fine... It is quite troubleing.

I have a hunch that the problem lies with how I am using dx and dy so I also attached my player.lua and main.lua.
Attachments
player.lua
(1.33 KiB) Downloaded 122 times
main.lua
(731 Bytes) Downloaded 121 times
collision_error.love
the love file
(11.12 KiB) Downloaded 125 times
It takes an idiot to do cool things. Thats why they're cool. :emo:
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Help with some Collision Errors

Post by davisdude »

The 100 and 300 blocks are the only blocks with problems I am experiencing: the character files around inside the block. Don't know why...
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
BulbaMander
Citizen
Posts: 65
Joined: Sat Dec 15, 2012 7:00 pm

Re: Help with some Collision Errors

Post by BulbaMander »

davisdude wrote:The 100 and 300 blocks are the only blocks with problems I am experiencing: the character files around inside the block. Don't know why...
Yea, that is the problem I am getting too, but on different occasions it will be different blocks. Sometimes they all collide fine, some times its just 200 and 600, sometimes its all of them.
It takes an idiot to do cool things. Thats why they're cool. :emo:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 44 guests