Alice Community

Alice Community (
-   Works-In-Progress (
-   -   Collision Detection! (

Dameria 12-01-2009 04:01 PM

Collision Detection!
1 Attachment(s)
I have been hearing a lot about collision detection and how it is so hard in Alice to make, so I decided to give it a try, and so far I think I have one part down really well in this program.

You move with arrow keys, and for now, if you try to move through the blue wall it will not let you, but as soon as you go to the side of the wall it will let you pass, try it yourself, hope you like it.

I am planning to also implement methods where you cannot go backwards through the wall, or through the sides of the wall, but I have no time right now. Tell me what you think please.

[i]If this program produces an error for you, please use x2495iiii's version below, although you will only be able to move forward[/i]

x2495iiii 12-01-2009 04:19 PM

1 Attachment(s)
Not a bad example. There was an error which generated after I let go of the up key, so I fixed that. Here you go.

Dameria 12-01-2009 04:23 PM

[QUOTE=x2495iiii;13775]Not a bad example. There was an error which generated after I let go of the up key, so I fixed that. Here you go.[/QUOTE]

I'm sorry, but when I tried your program it would not even let me go backwards or to the right, and mine works fine on my computer. Also on yours it goes significantly slower, I don't know what you did. If more people get errors when they let go of the up arrow key, then I will see whats wrong and try to fix it, but yours is not working for me.

Try downloading mine again and try it again. Maybe it downloaded wrong or something, and if it keeps happening then I don't know what would be wrong.

x2495iiii 12-01-2009 04:33 PM

Oh yeah. I was hoping you'd see what I did the the forward method and reproduce it when you made the other three directions' collision detection checkers.

You see, the error (which will probably happen to everyone) comes from ending an animation from inside an event by letting go of a key. For some reason, though, it works fine if you use booleans, like upHeld, to trigger and end the animation. For your forward moving method, there was a command for the cube to move for 100000 seconds (or something similar). This is the animation that was ended from inside the event, generating the error. I replaced the method calls in the events with boolean variable changes, which allows you to make the other three directions error-free as well, once they are made. Until then, all it will do is change the respective variables to true while held, and false when released.

Take a look at the moveForward method to see what I mean.

(EDIT: I re-dowloaded your to be sure, but yes, the error is still there. It happens to all "While a key is pressed" events which cut long animations short.)

(EDIT again: You can speed up the motion by changing the meters value in the moveForward method from .05 to something larger, like .1)

Dameria 12-01-2009 05:09 PM

ok, I never knew that. They seem to work on my computer for some reason.

Dameria 12-01-2009 05:36 PM

Hey, I think I found out your problem. Are you using Alice 2.0? I tried my program on 2.0 and the same error occurred when I tried it there.

I think they fixed that error for Alice 2.2. When using 2.2 I do not get those errors like in 2.0. Also, in 2.2 I cannot do While(true) and put a variable in the true part, and you can in 2.0, that is another reason why I think you might be using 2.0 instead of 2.2

Which version are you using?

dubastot 12-01-2009 06:37 PM

x249iiii always uses alice 2.2.:D

Dameria 12-01-2009 06:38 PM

did it work for you dubastot on 2.2?

dubastot 12-01-2009 06:42 PM

It works fine for me. That is some pretty ingenious coding you have there. I know how to use alice, but I am definitely not creative enough to think of all these great ideas.

Dameria 12-01-2009 06:49 PM

I'm glad to hear its not a problem that everyone is having, and to hear a person that has been hear longer than I have saying that my coding is good is a really good compliment! Thanks!

x2495iiii 12-01-2009 06:53 PM

That's odd. I've heard a bunch more people have the same problem as me. I wonder what triggers it, exactly...

Oh well. Either way, it is a good example of creative code. Great job, Dameria.

Dameria 12-01-2009 07:04 PM

Hmm, maybe I have a more updated version of 2.2? When I open 2.2 it says in the beginning,

"version 2.2: 8/1/2009"

Does it say that for you? Or might you have an earlier version?

dubastot 12-01-2009 07:32 PM

That is no different from anyone else's version. All that date means is when you downloaded and installed alice.

Dameria 12-01-2009 08:35 PM

Sorry this thread is about a specific part of Alice (collision detection) and your project has nothing to do with this thread. Post your own thread please in another part of the forum asking for help with your problem.

Dameria 12-04-2009 07:43 PM

1 Attachment(s)
I have created my final version of the Collision Detection Test (2.0). I have replaced the 2d box with a 3d Rectangular Prism, so it is more realistic. I have also fixed it so that it detects collision from all sides, and not just when trying to move through the front of it. Check it out!

I have deleted my first version in the first post and replaced it with 2.0. I will also have it available in this post, so you can download it from here. I created this to help give people a different perspective in collision detection, although this is mainly only good for when you need collision detection on only 1 building (unless you want to do a lot of work).

I hope you like it, please tell me what you think:

[i]If this program produces an error for you, please use x2495iiii's version, but it is not as up-to-date as Collision Detection 2.0[/i]

x2495iiii 12-04-2009 10:12 PM

Looks great and seems to work great, though the error persists for me.

Dameria 12-13-2009 06:59 PM

Does this help anybody else understand how to put in collision detection? I think I might even make another world where there are multiple objects, but still only 4 collision detection methods (one for each arrow key movement) in which there is an object parameter in the methods, so you have just have those methods for every object in your game that you want to have collision detection with.

Do you think I should work on that?

Delpenator 12-13-2009 07:14 PM

Whether or not you think my compliment is good or not,:rolleyes:especially since I don't know how to code collision detection at all, I'm gonna tell you anyway. That is the most complex do together - loop - while statement i have ever seen! And it worked perfectly!:D

Since i'm not really sure if thats a compliment, how's this. You rock!:p

But I still don't understand collision detection at all. :(

Dameria 12-13-2009 07:21 PM

Yea thats why I was thinking of making a simpler version of it that could work with more than just one object. Like where you can just enter the object that you want to have the collision detection, and it will work. I am thinking of making something like that (or trying to at least) but I am a lazy person so I would need to see if people want me to do it first.

Delpenator 12-13-2009 07:32 PM

I'd love that! ;) That would really help alot! Especially if you had a lot of comments... lol.:D

x2495iiii 12-13-2009 08:08 PM

I'd be interested in someone else's attempt at collision detection as well. Bouncing ideas off of other people always leads to the best solutions.

Dameria 12-13-2009 08:09 PM

So you would like to see someone else try to make a collision detection method then?

x2495iiii 12-13-2009 08:15 PM

Sorry for being vague, by "someone else," I meant you.

I'd like to see your attempt at making a simple, multi-object collision detection to see what I can learn from it.

Delpenator 12-13-2009 08:22 PM

1 Attachment(s)
Here is all i understand of collision detection. The beach house doesn't work that well, but thats because it's on stilts.

EDIT: Actually thought you meant someone else. Anyway this is the simplest form of collision detection and all i know.

Dameria 12-13-2009 08:27 PM

I guess that does solve the problem, but I noticed that I can still go through the building if I move sideways to it, I don't know why. I don't know, I might not make the program. I only make programs when I get excited about it, but I have already made a collision detection, I want to do something new.

reuben2011 12-29-2009 01:29 AM

I've made a multi-object collision detection for one of my games. I put all the objects that I didn't want the user to collide with in a list, and used a "for all together" which checked if the user was within [object from list]'s width. It was not perfect but it worked fine. The game is "fun ball game" or something like that, you can search the forum for it.

Veryuhbull 01-27-2010 08:14 PM

I posted a world of mine in a thread called collision detection in the share worlds forum. I am trying to make a buffer detection program that uses passive and active commands.

Zack Strife 02-06-2010 04:50 PM

I also have my own C.D. Method in share worlds if you want to check it out it works best for small or round objects, I will make one for a wall or building too.

Niteshifter 02-15-2010 01:00 AM

I actually had a fairly hard time trying to figure out how it worked, but I found out how it works.

Each movement is a completely seperate collision detection method and it checks to see if the object is within the cube's spacial area, despite what the code says (which is why I had a bit of a time trying to figure it out).

It can easily be broken if you adjust the size of the cube, but it can just as easily be fixed. I'd say that this is a promising detection function and I'd like to see it be used with multiple objects as well.

jediaction 02-15-2010 09:01 AM

I found a really nice way how to do collisions and im using it for my Hero's game. Its only for buildings though. Circle buildings work better but square is cool

shikhargo 08-17-2010 03:41 PM

I was wondering if someone could tell me how to make collision detection in alice2.2. Im a really big beginner.


jediaction 08-17-2010 05:12 PM

Ah, a beginner. K, well, collision in alice is known to be (very bad). We have created several collision programs all over the threads to help with your games. If you want to do the simple but not very reliable way of collisions that alice has. Make an event thats a while something is true. Select the world object and go to functions in the list of options on the bottom left. You should find near the top a button that says, "if "object" is within --meters" or something like that. Drag that in the "true" section of the event for the while something is true and set a distance. then in the begin, during, and end section, say what you want to do. Depending on how fast your going of how far your going to move backward. Always set the duration to "0 seconds" for most reliable collisions. Experiment a little with the speeds and you can change the collision camera move back speed or what ever object is moving. Hope i helped, and questions please ask.

Doctor Who 08-24-2010 01:48 PM

This is brilliant! Do you mind if I use this in my project, it is the only collision detector that will work.

Dameria 08-24-2010 06:08 PM

Yeah sure, everyone is allowed to use this method if they know how to.

Zippy133 10-07-2010 07:10 PM

Hey guys i tried ur program and i tried to copy the boxes and it didnt work. Only the box that was already in the program worked. im doin a school project and trying to make a maze where u cant go throught the walls!!!!
but thats kinda hard so i tried urs and it works fine but i cant duplicate the boxes. how did u get the box to work as a solid

Thanks Guys!!

All times are GMT -5. The time now is 02:23 PM.

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