Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
Collision Detection while walking
Old
BugMeNot
Junior Member
 
Status: Offline
Posts: 2
Join Date: Sep 2009
Question Collision Detection while walking - 12-03-2009, 03:09 PM

I am making an adventure-type game and have created a world. The game was working fine, except collision detection. He would simply walk through other objects. There are a few workarounds to this. The simplest one is the built in arrow-key control hit detection. If the camera is set to be controlled by arrow keys in the Events panel, the camera somehow automatically knows to not go through objects.

This would be perfect except by setting the person's vehicle to the camera, instead of moving forward from the person's perspective, it will move the person forward from the camera's perspective. The actual collision detection works great, except my character can no longer walk straight or even on a level angle (depending on camera angle).

Is there a way to use this built-in hit detection on other objects other than the camera? or, What is the best workaround for this situation?
Attached Files
File Type: a2w nov 3 backup.a2w (16.65 MB, 14 views)
   
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 12-03-2009, 03:14 PM

Short answer, no you can't. But you can make your own collision detection by using the "object is within x meters of object" function inside an infinity loop to constantly check to see if the character is touching an object (use object's width, another function, as the x value) and move that character away from the object.

Dameria wrote an early example of such a method, just search for collision detection and you should find it.


(')>
   
Reply With Quote
Old
BugMeNot
Junior Member
 
Status: Offline
Posts: 2
Join Date: Sep 2009
Default 12-03-2009, 03:25 PM

I am aware of the other workarounds, there are just so many objects in the world (this is a very ambitious project) that it would take a lot of code to do that for every object. And some objects are buildings, and the camera's built in detection can go through doors and such while the width-threshold detection would not.

Besides, the camera's collision detection works perfectly and it's a little frustrating that this same concept cannot be applied to other objects.
   
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 12-03-2009, 03:41 PM

It is frustrating, but apparently it was difficult to include that one collision detection method in the first place. The reason there aren't built in methods is because there isn't one which would satisfy all needs.

Say you need use special effects in the form of billboards and smoke in your world. If those objects were recognized as obstacles by a detection method, it'd be impossible to walk through a puff of smoke (unrealistic). Conversely, if they weren't recognized, custom walls would be nearly impossible to create, as one of the easiest ways to make a simple, processor friendly wall is to import a billboard with a stone or brick texture. This is why it's easier to have the user decide which objects to collide with and which to pass through.

As for doors, I see 3 options:
-drop the character and go to first-person format
-make a sort of "auto enter" which checks to see if you're close to a door, then lets you enter automatically with a key press
-make a complex set of if/else ifs to see if the character is close to the door or the wall and act accordingly


(')>
   
Reply With Quote
Old
Jeremytroid
Guest
 
Status:
Posts: n/a
Default 12-03-2009, 07:15 PM

Actually, it's quite simple.

Just do an "if/else" method set to 'character'. Then do "if 'character' is within 1 meter of 'object' move backward 1 meter" Else, do nothing.(click the character in the object branch and click "new method" then put the latter series of code)You only have to do this once and all objects should be solid.

I have a Mac and collision detection never works. So somebody try tell me if it works. It should work on PC. It does in my Mirror's Edge game.
Attached Files
File Type: a2w solid circus.a2w (749.7 KB, 16 views)
   
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 12-03-2009, 11:04 PM

Jtroid, your world didn't seem to work. It looks like the distance isn't large enough and the time it moves backward should be zero seconds and should only activate if the mole is moving forward (if it's moving backward, then it'll warp right into the fun house).


(')>
   
Reply With Quote
Old
reuben2011
Senior Member
 
reuben2011's Avatar
 
Status: Offline
Posts: 489
Join Date: Sep 2009
Location: Hawaii
Default 12-11-2009, 02:47 PM

To have collision detection for multiple objects you can always make a list of all the objects (call it something like dontCollideWith). Then make a for all together and use item_from_[array] as the objects when using the object is within [x] meters of object. Then as the distance, use item_from_[array]'s width or depth.
   
Reply With Quote
Reply

Tags
collision, detection, hit, move, walls

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.