Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Help with boundaries (http://www.alice.org/community/showthread.php?t=2633)

tyler-id 05-08-2009 05:01 PM

Help with boundaries
 
I'm working on a program, but I'm not sure how to create boundaries for objects, so that an object, if touching another, will be unable to move further, rather than going directly through it.
I'm sure I need to use If/Else, but I'm not entirely sure what to put in it to make it work.

EDIT: I guess it's called Collision Detection, what I'm trying to figure out.

tyler-id 05-08-2009 07:08 PM

I tried making an event that says
"While skeleton is within (tombstone's width / 2) of tombstone is true
Begin: Nothing
During: Nothing
End: world.collision tomb (which is a method that tells the skeleton to move backwards the same speed it moves forward with the up arrow presses)"

But, attempting to test it, the skeleton just moved backwards no matter where it was located.

EDIT: >< Idiot's mistake, just realized I had the world.collision tomb method looping in the world.start method...

EDIT: After fixing that problem, the event just isn't working properly at all. I'll be partway inside the tombstone, and then suddenly start bouncing around randomly.

EDIT: (Sorry for all the edits, but as I fool around trying to get it to work, new problems are going to arise) I tried switching it so that it says "While tombstone is within (skeleton's width / 2) of skeleton
Begin: Nothing
During: Nothing
End: world.collision tomb (changed the method so that rather than 'bouncing' back, it just moves a small amount so you can't really tell it's moving backward)"
It still does nothing. I changed it because I figured that the tombstone's width /2 wouldn't work well, because the tombstone is sort of oblong. Still does nothing though.

EDIT: I thought my trouble was with the method making the character move, but a test revealed that the program just isn't detecting collision at all.

HisWorld 05-08-2009 11:28 PM

Welcome!
 
WELCOME TO ALICE! haha, this is a major problem in alice as collision detection is not a very straight forward process.

You seem to be on the same idea as I was, "using half the width of an object" this is a good start.

Several problems do exist however:
One - The process you described will only really work properly on perfect sphere's, if you object is asymetrical obviously some parts are going to be farther away from the center than others.
Two - using this method assumes that alice will correctly find the center of the volume of the object, often it seems to calculate distance from other points such as the center of the farthest part of the back of an object.
Three - when using move commands such as move 3 meters forward, your command attempts at collision detection will not come into effect until the move is completed.

Here is a game I made in which i attempt to use some collision detection, I quickly gave up and moved on to other issues. [url]http://alice.org/community/showthread.php?t=2631[/url]

tyler-id 05-09-2009 02:06 AM

Thanks for your help, but I managed to figure it out on my own :)

[quote]One - The process you described will only really work properly on perfect sphere's, if you object is asymetrical obviously some parts are going to be farther away from the center than others.[/quote]

Yeah, I figured that, which is why I changed it to skeleton's width, because it's much more symmetrical than the tombstone. I eventually just scrapped the whole width /2 thing, and changed it to within 2 meters. It works pretty accurately now. Although, for more oblong shapes, it's a little sketchy.

I'll be sure to post the finished results :)

Thanks again.


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

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