Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
a collision of 2 balls?
Old
Sidew
Guest
 
Status:
Posts: n/a
Default a collision of 2 balls? - 08-28-2006, 03:50 PM

I want to do the following but I have been unsuccesful:

Having 2 spheres, make an event so I can move one of them with the mouse BUT when the ball I'm moving gets closer enough to touch the other ball Alice or message would appear saying "you crashed!" or something like that meaning that you have touched the other ball.

Thx in advance!!

Last edited by Sidew; 08-28-2006 at 03:53 PM.
   
Reply With Quote
Example of How to do Collision
Old
pausch
Director of the Alice Project
 
Status: Offline
Posts: 38
Join Date: Jul 2005
Default Example of How to do Collision - 08-28-2006, 06:18 PM

Here's a small program that shows how to do this...

hope this helps!
Attached Files
File Type: a2w TwoCollidingBalls.a2w (173.4 KB, 492 views)


Randy Pausch
Director of the Alice Project
   
Reply With Quote
Old
Sidew
Guest
 
Status:
Posts: n/a
Default 08-28-2006, 08:55 PM

Wow, thank you very much^^

Let me analize the code.
-The 2 meters it is supposed to be the distance from the centre of the ball to almost the outer part?, How did you know that(the exact distance)?

-For what is the WHILE expression (although I can suppose...)?, and the During parameter?

I have never used "While", that's why I ask. Thank you so much.
Cheers!!

EDIT: I used a "green'sBall Width instead of the "2 meters" in order to have the exact value.

Last edited by Sidew; 08-28-2006 at 09:14 PM.
   
Reply With Quote
Old
Sidew
Guest
 
Status:
Posts: n/a
Default 08-28-2006, 10:18 PM

Ok, I already found out.
Thank you very much!!
Any other solution is welcome.
   
Reply With Quote
1 more doubt
Old
Sidew
Guest
 
Status:
Posts: n/a
Default 1 more doubt - 08-29-2006, 05:05 PM

Hi again^^, I have just more doubt.

How do I make the collision TRUE?, I mean, if the green ball gets closer enough to the red one, I want the green one not going through the red ball.
Like if the red ball was a WALL, not allowing the green one coming through.

Thanks in advance.
Cheers!!

EDIT:

I tried something similar to this http://www.alice.org/community/showthread.php?t=69
If anybody knows an alternative, please tell it.
See you!

Last edited by Sidew; 08-29-2006 at 06:11 PM.
   
Reply With Quote
real collision detecting
Old
pausch
Director of the Alice Project
 
Status: Offline
Posts: 38
Join Date: Jul 2005
Default real collision detecting - 08-30-2006, 02:16 PM

Just as in the real world, it's much easier to detect conflict that it is to resolve it!

Unfortunately, there's an arbitrary amount of work you'll need to do in order to achieve various levels of satisfaction in changing the behavior of objects when they physically intersect, and there's no 'easy' answer I can give you.

I suspect you're going to end up doing some calculation that runs continuously and adjusting the position of various objects, but that can be as simple as just "keeping the last known position" and reseting a ball to that location when a collision is detected. That will make the ball appear to "freeze" even though I'm still trying to move it with the mouse.

In the limit, you'd probably want the balls to collide based on their velocity and mass, and bounce off walls, etc. It would (easily) be possible to have a team of 20 people working full time on getting this problem solved "right" (there are, in fact, such companies).

So it's not a simple problem you're trying to solve...

hope this helped!


Randy Pausch
Director of the Alice Project
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.