Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Works-In-Progress (http://www.alice.org/community/forumdisplay.php?f=14)
-   -   Collision detection engine (http://www.alice.org/community/showthread.php?t=3994)

zonedabone 02-26-2010 10:45 PM

Collision detection engine
 
2 Attachment(s)
Welcome to the collision engine! Please feel free to use this in your games, as long as you give me credit!

Required Sections:
[LIST][*]Collision method, and event calling it.[*]World variables.[*]All objects referenced to by the objects list.[*]A cylinder named "cylinder".[/LIST]Known Bugs:
[LIST][*]Main cylinder hovers. Fixed as of 1.1.[*]Cylinder might re-size erratically. Can be fixed by putting cylinders closer together.[*]Main cylinder appears to vibrate while against a wall. This is the location being corrected. It can be reduced by putting cylinders closer together.[/LIST]Todo:
[LIST][*]Add support for different types of obstacles. (i.e. squares, spheres, etc.)[*]Less memory intensive methods. This is to leave more memory with other methods.[*]Get a balanced time and distance for collision data setting. This will help to reduce vibration on the main cylinder, while hopefully not running the method too much. It is memory intensive to check every object![/LIST]Recommendations:
[LIST][*]The objects that you collide with can be invisible! Use Other objects for visuals, and leave the work to the cylinders![*]The program fixes collision data every quarter second. Setting the world variable "break" will override this, and cause the data to be refreshed immediately. This is good for when you change scenes.[/LIST]Current Version:
[ATTACH]2670[/ATTACH]

Current Engine(No other stuff):
[ATTACH]2671[/ATTACH]

Dameria 02-26-2010 10:55 PM

Wow, this is very nice and very smooth (although the coding doesn't really make sense to me, but hey, if it works then thats all that really matters! :D)

However, this is an [i]almost[/i] flawless engine. There is only 1 glitch that I have found so far, but it is a major one (sorta). Ok so you know there is a spot in top right that you can escape from the cylinder prison, but then go to the top left, once you are outside, to that gap that you can almost get into. If you wiggle around a bit, you find that you can somehow wiggle [b]over[/b] the gap, making you hover slightly, allowing you to get past the cylinders and the collision detection does not work from then on. (Maybe I should be a video game tester...)

zonedabone 02-26-2010 11:05 PM

Actually, I'm already working on a new engine that uses trig to calculate horizontal distance. Furthermore, you can just add another cylinder in that space. You know that you can move the cylinders, add more, and play as much as you want, so long as the list contains all of the cylinders? It's awesome!

Dameria 02-26-2010 11:11 PM

Yes, but if you run into a glitch like the one I did, the whole concept will be for nothing because the collision detection will not work anymore. If you add another cylinder there, then you may be able to do it in another part of the game.

zonedabone 02-26-2010 11:43 PM

Guess what? I added a method to the world. Every second, it runs what I call a "Maintenance script." It resets the vertical position of your cylinder! I can also add other things to it. I have it reset the positions of the others at the beginning, since they never move. Just remember that you can have as many of these as you want! I'm thinking of adding a side script that reduces the load on the main unit, though. I wouldn't be good to have 100 cylinders if 90 of them are obviously out of reach! Maybe this could be included in the maintenance script!

zonedabone 02-27-2010 12:01 AM

Breakthrough! The higher up on the events list an event is, the higher priority it is! That's great! I'll be sure to keep my collision there, and my maintenance at the bottom

Niteshifter 02-27-2010 12:06 AM

[QUOTE=zonedabone;17646]Guess what? I added a method to the world. Every second, it runs what I call a "Maintenance script." It resets the vertical position of your cylinder! I can also add other things to it. I have it reset the positions of the others at the beginning, since they never move. Just remember that you can have as many of these as you want! I'm thinking of adding a side script that reduces the load on the main unit, though. I wouldn't be good to have 100 cylinders if 90 of them are obviously out of reach! Maybe this could be included in the maintenance script![/QUOTE]

I might have an idea on how this could be achieved. Have the method find every object that is within a reasonable distance put into a "listen for" list at the beginning. Then after the maintenance script is run, it will iterate through the "listen for" list to remove objects out of range and add the objects within range (that is, if they are in the main list and not already in the "listen for" list to begin with). Then, have the collision detector use the "listen for" list instead of the main list.

zonedabone 02-27-2010 08:15 AM

I actually already was doing that, but thanks for the suggestion! Please spread the word! I believe that this is the smoothest and simplest collision engine out there!

King Gamer(gorit) 02-27-2010 03:09 PM

True
 
Ok, this works great except it only works ith cylinders and circle objects. It is however very simple which I give you props for. I will however continuw with my collision detection engine only because I like to have full control of what is hapening. I did see that you adressed the fact that methods are slower than functions. I will probably add your idea of only checking what is within 5 meters.

zonedabone 02-27-2010 03:31 PM

The best part is the two step filtering! the first step filters every 1/4 second, and does most of the work! The second filters the last couple things, and then just corrects it!


All times are GMT -5. The time now is 07:11 AM.

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