Alice Community  

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

Reply
 
Thread Tools Display Modes
Collision Detection within a list of objects
Old
kompsci
Guest
 
Status:
Posts: n/a
Question Collision Detection within a list of objects - 04-13-2011, 09:34 PM

hey, im making a fps where there are a bunch of zombies running towards the player(total of 16 zombies at the moment) and when you shoot them they disappear.
I created a list of zombie objects and got them all moving using the list and everything was working fine until i came to the problem of checking collision with the bullet that is fired from the gun at the zombie.
Previously i had checked for collision using each individual zombie object but with so many zombies i tried to implement a method that would loop through the list of zombies and check to see if the sphere had collided with said zombie.
It worked great in my head but not in the actual implementation. Below is my code in pseudo code-like form

Code:
infinite loop{

        for each zombie in zombie list{
    
              if(zombieCounter > numberOfZOmbies) // this resets the loopCount

                       zombieCounter == 0;
            
                       }
   
              if(bullet is withing 5 meters of itemFromZombieList){
  
                         destroy zombie or whatever

                     }
             
               increment loopCount by 1
 
       }

i think my problem is that i dont know how to refer to a specific index of my list. i want to be able to say if spher is within threshold of zombie at index loopCount but i can only seem to be able to say if its within ANY zombie object in the list. i hope my question is clear enough.

i got the zombies to disappear when the bullet hits ANY zombie and the zombies disappear in the order they appear in teh list. i cannot figure this out for the life of me

Last edited by kompsci; 04-13-2011 at 11:34 PM. Reason: i made some improvements but still not exactly what i want
   
Reply With Quote
Old
TheWhiteGuy
Guest
 
Status:
Posts: n/a
Default 04-14-2011, 12:34 PM

ok if u are using Alice 2.0 then what should work if u go and click on events and click <create new event> then do <when the mouse is clicked on something> then just change <something> to one of the zombies then create the method of it dieing/disappearing. That should work.
   
Reply With Quote
Old
kompsci
Guest
 
Status:
Posts: n/a
Default 04-14-2011, 05:22 PM

ok ill try that out
   
Reply With Quote
Reply

Tags
collision, list

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