Disable collisions on certain objects?

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
blackops7799
Prole
Posts: 13
Joined: Mon Apr 19, 2010 4:30 pm

Disable collisions on certain objects?

Post by blackops7799 »

Is there a way to disable collisions on certain objects while retaining collisions on others?

I'm currently working on a replica of the retro Atari Asteroids game.
http://i44.tinypic.com/t0nvwz.png

I need the asteroids to not collide with each other but allow the ship to collide with them? Is this even possible?
I've scanned the wiki for some info on disabling collisions and all I manged to find was something about making the object dynamic.

Think you could possibly add a new world callback that would act like so?

Code: Select all

function ShouldCollide( a, b, coll ) --return true or false to disable collisions 
	if a == "asteroid" and b == "asteroid" then
		return false
	else
		return true
	end
end
If there already is something like this could someone possibly point me in the right direction?
Thanks!
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Disable collisions on certain objects?

Post by bmelts »

You should read about setting category masks in Box2D - http://love2d.org/wiki/Shape:setCategory and http://love2d.org/wiki/Shape:setMask
blackops7799
Prole
Posts: 13
Joined: Mon Apr 19, 2010 4:30 pm

Re: Disable collisions on certain objects?

Post by blackops7799 »

Ahhh, thanks!
I'm just not exactly sure on how I would go about using it. :?

Nevermind, I figured it out. Thanks again!
User avatar
DmitryBochkarev
Prole
Posts: 2
Joined: Sat Apr 28, 2012 2:09 pm

Re: Disable collisions on certain objects?

Post by DmitryBochkarev »

Really good game!
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 5 guests