Mr Nemo
09-14-2006, 10:43 PM
Do you know if it is possible to create a generic method to handle a collision?
lanceA
09-15-2006, 08:37 AM
Try writing a specific collision detection function for a specific set of objects first. It will have to be a function in lieu of a method since it must return information to the calling routine. Once you have this working satisfactorily then review your code and think about how you might modify it to make it "generic".
Can you replace hardcoded data with variables that might be passed into the routine? Would passing the objects to the routine help it become more generic? What data, if any, should it return to the calling program? I'm currently returning a boolean value but a generic routine might need to return the current distance between two objects so that "evasive" action can be taken in advance.
I used that thought process to write my generic collision detection routine. However I must admit that it's only about 80% generic at the moment and I'm still tweeking it from time to time.
Perhaps others can add to this process and we can all learn.
Good luck