Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
collision detection?
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default collision detection? - 07-29-2011, 06:10 PM

I want to more about collision detection


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============
   
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 07-29-2011, 06:45 PM

As you know Alice does not have collision detection and you must make it yourself. Do you remember the thread where you asked how to make a gun shoot? Look in that thread and you will see that I included collision detection to determine whether you your bullet hit something or not. However lets recap........

The most common and basic form of collision detection uses the function :

Code:
object is within threshold of object
Now to implement this function into our collision detection lets create a new event. Which one should we choose well, the best one for collision is:

Code:
While something is true
If you go back and look at your old thread you will notice that instead I used the "When something becomes true," instead of the aforementioned event. I did this mainly because you can only die once, but you can walk into a building all you want.

So in your event bar you should have something similar to:

Code:
While <NONE> is true

Begin:<NONE>
During:<NONE>
End:<NONE>
Okay know for this example I am going to use two cubes. So go to first cube's functions and find the one similar to the function above. Click and drag it onto the very first <NONE> in our event; two popup menus will appear, one being about distance say one meter and the other being about which object you want to collide with,cube2. You should have:

Code:
While cube is within 1 meter of cube2 is true

Begin:<NONE>
During:<NONE>
End:<NONE>
Almost done!

Okay now when you hit something such as a wall, what do you do? You move backward, and this is exactly what we are going to do.

In the during section of your event you are going to add an event from the cubes methods, more specifically the move method. So move your method into the during and set the direction to backward, and you are done!

If you still don't understand here is the above coding in an actual world. Th only exceptions are that I added a moving event and replaced the move method with the move at speed method, mainly because it runs smoother.

Oh and as a side note sorry I did not finish my post on your thread I have been kind of busy lately; I will get to it....eventually.
Attached Files
File Type: a2w collisionExample.a2w (166.5 KB, 74 views)


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein

Last edited by legolizard; 07-31-2011 at 01:10 PM. Reason: grammatical error
   
Reply With Quote
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default 07-30-2011, 02:01 PM

Actually, this doesn't work......
I made a barn and a shotgun, but after I do what you are telling me to do, the shotgun still can move through the barn.........

This is my world (when you are playing it move with W, S, A, and D buttons and the barn is behind the camera so, hold down S and you will move through the barn).......
Attached Files
File Type: a2w City Grave.a2w (1.76 MB, 11 views)


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============
   
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 07-30-2011, 03:06 PM

Well first of all you did not do what I had said above. But if you did and put up the wrong world then here is a more detailed perspective on collision.

You see ever object has what are called axes and pivot points, even in the real world everything has axes and pivot points. The difference is, is that in the real world collision is caused because that is a propterty of matter and pivot points have no role in collision while in Alice collision is created by determining distances between pivot points So, in most objects the pivot point is in the center. Why am I saying this? Well because of this you can't just always use 1 meter as a suitable distance because that is what it would be in the real world. Instead you must think distance wise.

Here is your world with a few modifications:
City Grave (1).a2w

Now on thing you may dislike is that you can't walk very far into the barn. Why?Well again the barn has only one pivot point and so it is only going to detect for that one. One thing you can do is add three squares to detect for collision with them like this:

City GraveAlternate.a2w


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
   
Reply With Quote
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default 07-31-2011, 05:58 AM

I don't know......but I did what you did......
look....here is what I did.......
Attached Files
File Type: a2w City Grave.a2w (1.76 MB, 5 views)


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============
   
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 07-31-2011, 09:39 AM

Couple of things you did not follow.

1)One of the reasons why I discussed pivot points above was because the bigger you make the object you want to collide with the larger the threshold number must be because of the discrepancy between pivot points distances'. So instead of 25 meters make it 95 meters, just fiddle with the number until you like the results.


2) In your world when you press and hold 'w' you move at 30 meters per second, however when you collide with something you only move backward 25 meters per second, these numbers must be equal.

Again understand that you really won't be able to go into the barn, for that look at my above post's second attachment.


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
   
Reply With Quote
Old
Nighthawk0973
Senior Member
 
Nighthawk0973's Avatar
 
Status: Offline
Posts: 240
Join Date: May 2011
Location: In front of my computer.
Default 07-31-2011, 02:47 PM

It would be nice if you could make an event like this:

Code:
While Something is True

BEGIN
DURING
END
Code:
While Camera is within <1 Meter> of <Nothing>

BEGIN
DURING 'Camera Collision Method'
END
That way you could just scatter cubes in places where the models axis is too far away for collision to trigger.
   
Reply With Quote
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default 07-31-2011, 03:05 PM

Look..that doesn't achieve my aim............
I want to make all objects unable to move through the barn except from its doors.........
here is my world after modification (according to your guidance and I tried 95 and other many number but this makes the camera unable move beside the barn in a certain area and I tried to change barn with barn.leftMainRafer and others but also that doesn't achieve what I want......)
Attached Files
File Type: a2w City Grave.a2w (1.76 MB, 8 views)


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============
   
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 07-31-2011, 07:40 PM

*sigh* I know, I told you about that. Again when you think of stuff you can collide with you think of walls, Alice does not work that way it detects for if the distance between the center of the barn an the center of the camera are within 95 meters of each other. If you don't understand my second attachment above, then allow me to explain.

Go to Add objects>shapes and then find a square. Import it into your world and align the square to cover all three walls you do not want to go through. Like so.....

capture00.jpg


Once you are done go to each squares properties and set "isShowing" equal to false so that you don't see the squares any more. Now instead of detecting for just "the barn" we are going to detect for three things; square1, square2, and square3. So there are two ways to detect for collision between multiple objects. You can....

A)Use three events similar to the ones above except you will have to change the numbers a bit through the ever wondrous method of trial and error.

or....

B)Use one event and some || or, "either a or b, or both" operator.

Either way you they should be similar to the above.

I am sorry if I am not the best teacher.
l.a2w


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein

Last edited by legolizard; 07-31-2011 at 09:46 PM.
   
Reply With Quote
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default 08-01-2011, 04:57 AM

Listen to me.......
you are the best, but I want to know how to make the cubes cover the barn?


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============
   
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.