Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / SetSpriteGroup - Box2D Physics [Tier 1]

Author
Message
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 21st Sep 2012 18:38 Edited at: 23rd Sep 2012 13:50
I'm trying to create two sprites with Physics, one static and the other dynamic... I want the dynamic sprite to be able to pass through the static sprite? Is this possible? I have tried SetSpriteGroup, but believe this is only used for collision detection and not actually physics?



EDIT: Added code snippet...
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 21st Sep 2012 18:45
Try to set up physics with SetSpritePhysicsOn, setting to Static (code 1), and then setSpritePhysicsSensor. The sensor does not react but it is capable to detect collision, and can be transparently crossed by a physic sprite.
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 21st Sep 2012 18:49
SetSpritePhysicsIsSensor() is the one I'm after!! Thanks MarcoBruti... Onwards and upwards!!
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 21st Sep 2012 19:54
I have not tried these yet but you can assign sprites to categories (1-16 I think).

SetSpriteCategoryBits()
SetSpriteCollideBits()

The top probably sets which category the sprite belongs while the second command sets which categories the sprite should collide with.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Sep 2012 20:04
I use the SetSpriteCategoryBits() and SetSpriteCollideBits() fairly effectively.

But having just been introduced to SetSpritePhysicsIsSensor, I can see some great applications for its use.

Cheers,
Ancient Lady
AGK Community Tester
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 22nd Sep 2012 10:26
Why dont you simply use negative groups?

You can also set -1 to -16 in the groups where all sprites in -1 one will pass thru each other.

Android 2.3 Gingerbread , ZTE Skate , 480x800 , 800 mhz cpu , Samsung Galaxy Y , 240x320 , 832 mhz cpu
Android 4.0 Sandwich , Dmtech 3g 9738B , 1024x768 , 9.7 inches , cortex A8 1.2 cpu , 1 gb ram.
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 23rd Sep 2012 13:52 Edited at: 23rd Sep 2012 13:56
Quote: "Why dont you simply use negative groups?"


I don't think that works. I tried all different combinations of both negative and positive groups. I couldn't get any of them to work... Anyhoo, SetSpritePhysicsIsSensor() works perfectly for me. Thank you for all the replies...

EDIT: Actually, just tried it again. You have to use the same group id if you want them to pass through each other... That seems counterintuitive to me, I would have thought you'd need different group id's and only those within the same group collide?
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 23rd Sep 2012 14:31
Quote: "I don't think that works. I tried all different combinations of both negative and positive groups. I couldn't get any of them to work... Anyhoo, SetSpritePhysicsIsSensor() works perfectly for me. Thank you for all the replies...

EDIT: Actually, just tried it again. You have to use the same group id if you want them to pass through each other... That seems counterintuitive to me, I would have thought you'd need different group id's and only those within the same group collide? "

Its pretty clever if you think of it!

Putt all enemys and pickups in group -1 and they collide with all other groups but not each other.

I used sensor before this and found this to be better.

Android 2.3 Gingerbread , ZTE Skate , 480x800 , 800 mhz cpu , Samsung Galaxy Y , 240x320 , 832 mhz cpu
Android 4.0 Sandwich , Dmtech 3g 9738B , 1024x768 , 9.7 inches , cortex A8 1.2 cpu , 1 gb ram.

Login to post a reply

Server time is: 2024-05-04 06:49:39
Your offset time is: 2024-05-04 06:49:39