Collision Detection with variables -
09-28-2011, 11:33 AM
How does one make a collision detection system that doesn't involve simply making an event the involves 2 objects?
I want to be able to define a set list of objects that will be the only ones that are detecting.
Ex: a car with a bunch of buildings around it, making it react when it collides with the buildings, but without making a separate method for each building.
If [Car] (Collision with building one here)
If: [Car] Move back [0.1] meters Duration=0
Else:
If [Car] (Collision with building two here)
If: [Car] Move back [0.1] meters Duration=0
Else:
If [Car] (Collision with building three here)
If: [Car] Move back [0.1] meters Duration=0
^Use that sort of thing.
[COLOR=e4eaf2]Your text here[/COLOR]
Come on, you know you want to try it.
Make a list or array variable with a series of objects that are to be your collision proxy.
Then, make an if statement containing a do for all together that detects if your object is near the collision proxy.
You said methods, but I apologize for misunderstanding.
Apology accepted, I realized after that I had indeed asked for methods, which is what you gave me, but thank you all for your help. Perhaps now I can inch closer to finishing this project...
Tried to implement what you suggested...and it didn't work. Not sure if I didn't do what you had in mind or if Alice just doesn't like me, but I'm attaching the world I put it in. You might wanna take a look at the other methods and events I have and see if they might be affecting it.
I made a maze world a long time ago to demonstrate collisions with a bunch of walls that are all in a list. It just checks to see if the person is touching anything in the list and it pushes it back if it is. The problem is though that it only works if you put up walls, rectangles. You would have to tweak it to make it work with other objects, but it works fine if you just put a bunch of walls around the objects where you don't want it to pass through.