annoying container picking

Post your own tutorials, guides and demos.

Post » Wed Aug 13, 2008 1:35 pm

I absolutly love containers, however this is a little annoying:
when you have two objects A and B in a container, call them A1 B1 for container instance 1 and A2 B2 for instance 2

if A1 overlaps B1 it picks fine
if A2 overlaps B1 it picks both B1 and B2 which is annoying

as shown in attached cap

anyone got a workaround?
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Wed Aug 13, 2008 2:16 pm

Firstly, use the drag and drop movement! If you drag too fast, the objects are left behind with your code :P

This is precisely how containers work. 'A overlaps B' naturally picks both the A instance and the B instance, which also picks the entire container of A and entire container of B.

So what you want is to ignore the blue object's picking in this condition. You only want to pick the object that it was collided with, to save picking the blue object's own container as well.

I've come up with a really funny workaround for this! Lets say A is the orange object, and B is the blue one.

Use:
+ A overlaps B
+ For each A
+ A overlaps B
-> Set A X position to .X + 10

I *was* writing a short description of how it works, but to be honest, I can't figure out why this works. I would have thought the second condition would have still picked the entire container, but somehow the for-each overrides it. Ummm... I'm not sure if this is intended behavior or a bug. Hell, I say it's intended behavior. Because then, your problem is solved ;)
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Wed Aug 13, 2008 2:55 pm

haha thanks alot for the speedy response and workaround. Yeah I didnt really think it was a bug, I mean I expected that might happen I just couldn't see a way around it.

lol, yeah I know that drag and drop thing was terrible, to be honest I haven't looked at the behaviors that much apart from physics and RTS, if this was an actual game or anything instead of a crappy little example I would of course have made it a lot better! Maybe in future I'll consider the behaviors :mrgreen:

EDIT: ahhh when I do that it crashes when it overlaps the one in the other container (reproducing a crash yay!)
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Wed Aug 13, 2008 3:18 pm

OK weird... it works if you use a drag+drop behavior, but with your own drag events it crashes. I'll look later. :?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Wed Aug 13, 2008 3:20 pm

thats really weird, anyway, it works where I needed it to - so thats alright

EDIT: was just thinking, maybe you could have some sort of "is not in container" condition, so you could have like A overlaps B and A is not in same container as B then it would pick the A and B that aren't in the same container - would be more intuitive than a for each object loop and another overlap condition which (by your own admission :P ) is confusing.
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Wed Aug 13, 2008 4:58 pm

ok so I had to make it more complicated, and that broke it and now I can't make it work again.

I need it to pick BOTH the objects, which by itself I managed, by copying the event and changing A to B and B to A - but now I need to only pick them when each of their private variables is a cirtain value

I made a cap demonstrating my attempts and now I'm completely stuck - I've tried everything I can think of.
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Wed Aug 13, 2008 9:16 pm

I have gotten slightly further (attached), but it is still bugged, and really horribly done. It seems to work like it should, but then when the correct ones overlap eachother and are picked, and you bring the other ones to collide with them, it stops it being picked :( .

Basically I can't make this work, and I'm getting really frustrated by it lol
so I am offering some incentive... if someone solves this, I will donate up to 10 to scirra, depending on the elegance of the solution (I am a student, so thats quite a lot of money to give away :lol:)

1 event would be awesome, but if its like 20 events and loads of horrible private variables its only worth like 1 :twisted:
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Tue Aug 19, 2008 4:44 pm

I'm gonna bump this because I still haven't found a solution and my offer still stands.
[size=200:3ori1gkg]IF YOU SOLVE THIS I'LL SEND ASHLEY 10[/size:3ori1gkg]
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Tue Aug 19, 2008 10:17 pm

More flexibility with collision conditions is a common request, so I've added two new conditions for the System object in the next build: On Collision (advanced) and Is Overlapping (advanced). This has two object parameters to pick the objects involved in the collision, and two combo boxes - Pick or Don't pick - allowing you to customise which objects are picked by the condition.

So, in this case, you can use:

Blue (don't pick) overlaps Orange (pick): Set Orange X to .X + 10

Then your example works fine: since Blue is not picked, it doesn't pick the Orange in its container, only the one it's colliding with. And it all works beautifully :)

You should only use the advanced collision conditions when you need the specific picking behavior though - I don't think they're quite as fast as the usual ones.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Wed Aug 20, 2008 12:03 am

[quote="Ashley":3gbhkvt5]More flexibility with collision conditions is a common request, so I've added two new conditions for the System object in the next build[/quote:3gbhkvt5]

:shock:

Wow, that sounds awesome
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest