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 / Is there a Contact List for non-physics sprites?

Author
Message
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 30th Nov 2015 22:39
Hello,

I've been wondering if there is a contact list for non-physics sprites. I'd like to be able to utilize the internal contact list and the contact methods: GetFirstContact, GetNextContact, GetContactSpriteID1, and GetContactSpriteID2 (are there more?). Currently I have a check for collision that iterates over an array of active sprites and checks collision using GetSpriteCollision, but it may become too cumbersome to manage an array in the future if there are too many assets on the screen; especially since I have to loop twice to check if the first iteration of assets also collide with the second iteration of assets (that are not itself). Did that even make sense? So far this approach works, but I'm not a fan. Another work around I have tried is assigning physics to the sprites and utilizing physics' contact list when handling the collisions to avoid looping over a bunch of stuff that may, or may not, have collided with something.

Thanks, ahead of time!
-mrradd-
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Dec 2015 16:31
Unfortunately only the physics system generates contact lists
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Dec 2015 18:05
there are similar commands that give you only the contact list from a given sprite
GetSpriteContactSpriteID2 ( )
GetSpriteContactWorldX ( )
GetSpriteContactWorldY ( )
GetSpriteFirstContact ( iSprite1 )
GetSpriteNextContact ( )
GetSpriteGroup



AGK (Steam) V2.0.15d : Windows 10 Pro 64 Bit : AMD (15.201.1151.0) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 3rd Dec 2015 21:46
@Markus I have done something similar to that in the past which is fine, and works well. With my implementation I would still need to iterate over an array to get the sprite's id (in you example it would be 'ball'), and then iterate again to check if it collided with something.

The reason I asked is because I do not want to use physics to move my assets for my particular scenario. My "workaround" to use the contact list is to make everything that can be collided into a physics object. Then I ran into another issue. It seems like only sprites with Dynamic physics on the contact list (I hope I am wrong about this). This bothers me since I have to save the coordinates of my assets, and set the position every cycle, or else they fall to the ground. I also don't want to use force to stabilize them since I want them to be static. Please tell me I am doing something wrong, and that static sprites do go on the contact list!
-mrradd-
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Dec 2015 22:46 Edited at: 3rd Dec 2015 22:49
dynamic vs static get also a contact list with physics. did you moved static sprites? there is also kinematic mode and set as sensor.
without physics there also 2 useful commands
GetSpriteInBox ( iSprite, x1, y1, x2, y2 )
GetSpriteInCircle ( iSprite, x1, y1, radius )

AGK (Steam) V2.0.15d : Windows 10 Pro 64 Bit : AMD (15.201.1151.0) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 3rd Dec 2015 23:55

@Markus I am moving the sprites with Static physics by way of SetSpritePositionByOffset(). Does this affect how they are handled for contact checking?
-mrradd-
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Dec 2015 00:15
I thought so. yes, that skip the physics.
AGK (Steam) V2.0.15d : Windows 10 Pro 64 Bit : AMD (15.201.1151.0) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 4th Dec 2015 00:36

Well then. That's unfortunate... I'm glad I asked since I was getting really confused as to what I was doing wrong. Do you or Paul know why that is? I was considering making a moving platform using static, but now I will definitely not.

I realize I have other options, but I really wanted to use the internal contact list since it was managed for me. Thanks, for the assistance! You saved me a ton of headaches debugging code that worked, but not as I expected haha.
-mrradd-
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 4th Dec 2015 07:41 Edited at: 4th Dec 2015 15:06
Edit. I was talking nonsense.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Dec 2015 12:20
Quote: "I was considering making a moving platform using static, but now I will definitely not."


i can agree, this physics system is not easy to handle because of unexpected results.

in this exapmle i used a platform with a mousejoint and set the target only.

AGK (Steam) V2.0.15d : Windows 10 Pro 64 Bit : AMD (15.201.1151.0) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 10th Dec 2015 16:17 Edited at: 10th Dec 2015 16:17
@CJB
Quote: "Edit. I was talking nonsense. "

I didn't see what you posted, sooooo AWESOME!

@Markus
Quote: "...i used a platform with a mousejoint and set the target only."

Ooooooohhhh that is very interesting--you opened a whole new set of doors for me to explore. I really don't want to go back and refactor right now; however, in the future (maybe before release or in another game/app) I will definitely keep this solution in mind. I have't played with joints at all, and I especially did not know they behaved like that. I really like that idea. Unfortunately I saw this too late.

I still consider myself a noob I can only really spend maybe an hour at a time with AGK2, because reasons, and an hour every few days since February 2015 isn't too much exposure, but I know enough to be dangerous haha. This is my first game/app/thing I want to put on the market so I am trying to make it "good-ish" enough for people to think, "Hey I can play this on the John, so I'm not bored." Play testers seem to enjoy it so far, but this joint thing could add another fun element to it.

THANKS!
-mrradd-

Login to post a reply

Server time is: 2024-11-25 13:47:48
Your offset time is: 2024-11-25 13:47:48