Alice Community  

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

Reply
 
Thread Tools Display Modes
Object Collision
Old
Matchewawa
Member
 
Status: Offline
Posts: 32
Join Date: Feb 2011
Thumbs up Object Collision - 02-17-2011, 11:06 PM

I'd like to set collision on objects so that I can't go through them, also onto the old west terrain so that I stay on top of it as I walk over it, but I don't know how. Any tips?
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 02-17-2011, 11:18 PM

That one's harder to do. Much much harder. Dameria's the only guy to ever get tangible, large-scale results, and that was from several hours of work. Basically its boiled down to putting a bunch of squares on every surface you don't want the character to run into, then have a constant string of if/else if statements which check to see if the character is in front of those square and pushes him back if he is. The terrain thing can't be helped, as far as I know.

If you want more info on his method, search his posts or just ask him.
   
Reply With Quote
Old
reuben2011
Senior Member
 
reuben2011's Avatar
 
Status: Offline
Posts: 489
Join Date: Sep 2009
Location: Hawaii
Default 02-17-2011, 11:20 PM

i see. To test collision, you need to take into account the distance between the objects' centers and the width of the objects. For example if you want to make a variable called isColliding become true when the objects collide, I would do something like this:

if (((distance between object A and B) - (objectA.width / 2) - (objectB.width / 2)) <= 0)
{
isColliding = true
}

I actually haven't used alice for awhile, so the syntax and the function names of the above might be slightly different. If you still need help, like if you need me to translate the above into step-by-step instructions for Alice, I'll help you if need be. Hope this helps!
   
Reply With Quote
Old
reuben2011
Senior Member
 
reuben2011's Avatar
 
Status: Offline
Posts: 489
Join Date: Sep 2009
Location: Hawaii
Default 02-17-2011, 11:23 PM

Quote:
Originally Posted by x2495iiii View Post
That one's harder to do. Much much harder. Dameria's the only guy to ever get tangible, large-scale results, and that was from several hours of work. Basically its boiled down to putting a bunch of squares on every surface you don't want the character to run into, then have a constant string of if/else if statements which check to see if the character is in front of those square and pushes him back if he is. The terrain thing can't be helped, as far as I know.

If you want more info on his method, search his posts or just ask him.
x2495iii, I don't know if you saw my other game before, but I basically put all the collide-able items into an array (or list, I forget) and ran each item through a method of some sort to see if the "character" was colliding with any of the items in the array.
   
Reply With Quote
Reply

Tags
object collision terrain

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 ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.