Is it possible to exclude one group of shapes from collision with cpSpaceSegmentQueryFirst without using different layers?
I'm trying to implement laser ray shooting and don't want to hit shooter's shape while it still can collide with other shapes.
Excluding groups
-
- Posts: 3
- Joined: Sat Sep 28, 2013 12:43 am
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Excluding groups
Yes. It's actually the same answer to a slightly different question from this morning here:
http://chipmunk-physics.net/forum/viewt ... 076#p12907
You use the "group" property of a shape actually. Your question was so close to answering itself.
http://chipmunk-physics.net/forum/viewt ... 076#p12907
You use the "group" property of a shape actually. Your question was so close to answering itself.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 3
- Joined: Sat Sep 28, 2013 12:43 am
- Contact:
Re: Excluding groups
Omg, I just thought this property works in opposite way
Thanks for make it clear for me!
By the way, if I ever want to hit only one group except others, what should I use in this case?
Thanks for make it clear for me!
By the way, if I ever want to hit only one group except others, what should I use in this case?
-
- Posts: 15
- Joined: Mon Oct 28, 2013 10:55 pm
- Contact:
Re: Excluding groups
Wait, so using a group in a cpSpaceSegmentQueryFirst call will exclude that group? If that's the case then I thought it was the opposite as well.AntonyDream wrote:Omg, I just thought this property works in opposite way
Thanks for make it clear for me!
By the way, if I ever want to hit only one group except others, what should I use in this case?
-
- Posts: 3
- Joined: Sat Sep 28, 2013 12:43 am
- Contact:
Re: Excluding groups
Yep, that was an unexpected turn for me toodrey08 wrote: Wait, so using a group in a cpSpaceSegmentQueryFirst call will exclude that group? If that's the case then I thought it was the opposite as well.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Excluding groups
That's a common misconception actually. :-\ While it's intuitive that the layers work the same for queries and collisions, people often think that groups work the opposite way.
@AnthonyDream If you want it to work the other way around, you can always implement the callback based iterator and filter them yourself. The "nearest" and "first" versions of the query functions don't really do anything particularly special**. Zamaster has a good description here: http://chipmunk-physics.net/forum/viewt ... 916#p12906
** Not exactly true. It's built on the spatial indexing function which work similarly, but make it possible to exit a query early. https://github.com/slembcke/Chipmunk2D/ ... ery.c#L111
@AnthonyDream If you want it to work the other way around, you can always implement the callback based iterator and filter them yourself. The "nearest" and "first" versions of the query functions don't really do anything particularly special**. Zamaster has a good description here: http://chipmunk-physics.net/forum/viewt ... 916#p12906
** Not exactly true. It's built on the spatial indexing function which work similarly, but make it possible to exit a query early. https://github.com/slembcke/Chipmunk2D/ ... ery.c#L111
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 18 guests