Alice Community  

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

Reply
 
Thread Tools Display Modes
Lagless collision detection?
Old
sam.no21
Guest
 
Status:
Posts: n/a
Default Lagless collision detection? - 06-04-2010, 02:34 AM

Is there any way to reduce the lag when using loops for collision detection?
I find if I make anything to big or complicated using infinity loops the world will struggle to run.

All help appreciated!
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 06-04-2010, 11:14 PM

Try putting in a Wait statement into your infinite loops. Some things, like collision, cannot really have too much of a long wait or else it will not function right, but if you have any infinite loops that do not require a constant checking, put a 1 second wait on it (or less if you need to it check more often).

For collision detection, I use an infinite loop to determine how far away I am from a certain group of objects, and those objects are in a list. The infinite loop only runs every 0.5 seconds, and if it is near the group of objects it starts the collision for that group of objects, and then if you go far enough away from the group of objects, the infinite loop checking every 0.5 seconds to see if you are close to the group will turn a boolean variable back off, and the collision will stop on that list.

It is quite complicated, but I actually got it to work on one of my worlds that I have not yet published. I have 4 groups of objects, and there is a boolean for each determining if I am in a certain range of the objects to turn it on. Once the boolean is turned true, the collision is started in a while statement, with the boolean being the argument, so that once I go far enough away from the objects the boolean goes back to false and the collision stops, making it about 30 less infinite loops running at once, significantly helping to reduce the lag.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default 06-06-2010, 07:11 PM

Thy this.
http://www.alice.org/community/showthread.php?t=3994


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
sam.no21
Guest
 
Status:
Posts: n/a
Default 06-13-2010, 08:19 PM

Thanks for the ideas!
I have built a grid of cubes over my world. Each cube can determine what objects are in it so that the colision detection is only on for the object in the cube that the person is in.

The next problem that I have is that I need to have a huge set of if statements to access the lists stored in each cubes variables (I have had this problem for many other things). Any ideas? Pic attached

   
Reply With Quote
Old
Rabizaman
Guest
 
Status:
Posts: n/a
Default 06-14-2010, 01:30 AM

Some threads are really unique. Forums are for the benefical of people. This Thread is an exmaple of good post.
I have the same question running in my mind and thank you my question has been solved now. The same Forum and topic
i read on forextradingevo. com , nice forum and nice comments always appreciated by the people.

Keep posting ...
   
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.