Alice Community  

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

Reply
 
Thread Tools Display Modes
Help with boundaries
Old
tyler-id
Guest
 
Status:
Posts: n/a
Default Help with boundaries - 05-08-2009, 05:01 PM

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.

Last edited by tyler-id; 05-08-2009 at 06:50 PM.
   
Reply With Quote
Old
tyler-id
Guest
 
Status:
Posts: n/a
Default 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.

Last edited by tyler-id; 05-08-2009 at 07:42 PM.
   
Reply With Quote
Welcome!
Old
HisWorld
Guest
 
Status:
Posts: n/a
Default Welcome! - 05-08-2009, 11:28 PM

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. http://alice.org/community/showthread.php?t=2631
   
Reply With Quote
Old
tyler-id
Guest
 
Status:
Posts: n/a
Default 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.
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.
   
Reply With Quote
Reply

Thread Tools
Display Modes

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.