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 Studio Chat / Overlapping Collision checking

Author
Message
haliop7
User Offline
Joined: 1st Mar 2022
Location:
Posted: 27th Jul 2022 17:53
Hi.

I have 3 sprites.
1st, depth is set to 1 and is somewhere on the screen.

2nd, depth is set to 2 and is somewhere on the screen.

and 3rd, which overlap the entire screen, but! depth is set to 10.

now let's say that the first 1 is 10x10 in size and the second is 20x20, so if the first one overlap the second one let's say in the middle of the 2nd. collision works well.

however, because the 3rd overlaps the entire screen, it returns that it hit that one rather than the 2nd one whose depth is in front of the screen.

I usually thought that if you use Depth and collision checking, physical or not, it will catch the ones that depth is closer. this shows that no matter the depth, a far behind sprite and a closer sprite (both physics and no physics collision checking) kinda mess up the collision checking.

so is there a way to check collision by depth, without doing so much work behind the code, cause then I will kinda need pixel-perfect collision which I am not after right now (although is extremely simple using Memblocks and low resolutions of a render Image, just do not want to do it right now).

any ideas to keep it simple?

P.s
missed you a lot. thank you for your time.
Prime
User Offline
Joined: 15th Jun 2022
Location:
Posted: 28th Jul 2022 01:19
haliop7
User Offline
Joined: 1st Mar 2022
Location:
Posted: 28th Jul 2022 23:30
So let's say that all the sprites are in the same group but at different depths.
so for say if it was 3d, 1st is checking with the 2nd, and then checking with the 3rd, right? but 3d is different.

so I am trying to imagine this as a 3d but 2d, where in 3d, if I have 3 boxes if the 1st collides with the 2nd but there is an adjacent space where the 1st has some space that does not collide with the 2nd, then, it falls beneath colliding with the 3rd one.

like 3 boxes. 1 small, 2 medium, 3 the entire screen.
only if 1 is inside 2 then it's ok, if it is outside then it hits the 3rd one. but depth does not help here, and the collision is checking with both, as all are in the same group needed to be checked.
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Jul 2022 04:42
I'm not aware of collision ever using the sprite's depth as a factor.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

haliop7
User Offline
Joined: 1st Mar 2022
Location:
Posted: 29th Jul 2022 05:44
Yeah, so I wanted to check if there is a way to check it.
I'll wait a bit, maybe someone has a good idea.
blink0k
Moderator
9
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Jul 2022 21:52
Quote: "so I am trying to imagine this as a 3d but 2d, where in 3d, if I have 3 boxes if the 1st collides with the 2nd but there is an adjacent space where the 1st has some space that does not collide with the 2nd, then, it falls beneath colliding with the 3rd one."


This would be considered pixel perfect collision because you want to check part of sprite1 against sprite3.
I do not think there is any collision functions that would accomodate this.
It might be possible with a shader
Virtual Nomad
Moderator
16
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th Jul 2022 23:33 Edited at: 29th Jul 2022 23:40
Not too difficult to see if an entire sprite shape fits within another completely (if i read that right) but ur well beyond "a command or 2" handling with the depth stuff on top, so...

Otherwise, i'd get box2d involved for quick reference to a given sprite's contacts as a starting point and apply your other tests against those
haliop7
User Offline
Joined: 1st Mar 2022
Location:
Posted: 30th Jul 2022 09:34
I was thinking of rendering everything into an image and turning it into a memblock.
Using that temp image in really low-resolution values
Iterate and check, Using cycles or "Skipping" frames inside the main loop to get quick results.
smerf
17
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 3rd Aug 2022 19:33
the draw order will affect sprite depth especially if there drawn at different times u can manualy draw the sprite when u want with update render. also on mouselick u can move the big sprite check for collision and move it back before a screen update it will never be visible to the user. also a custom user type can be made that has depth and coords and u can just check for collision withing box coord and filter buy depth. I use sprite depth all the time never seem to have any problems with it

Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Aug 2022 18:21
If you want pixel-perfect collision as Blink suggests, you can implement your own system to work with depths based on my code example:
https://forum.thegamecreators.com/thread/219444
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

haliop7
User Offline
Joined: 1st Mar 2022
Location:
Posted: 6th Aug 2022 02:34
Ok.
I think for fun, I'll build a simple pixel collision that simplifies the process.

Login to post a reply

Server time is: 2022-08-07 16:51:43
Your offset time is: 2022-08-07 16:51:43