As you know Alice does not have collision detection and you must make it yourself. Do you remember the thread where you asked how to make a gun shoot? Look in that thread and you will see that I included collision detection to determine whether you your bullet hit something or not. However lets recap........
The most common and basic form of collision detection uses the function :
Code:
object is within threshold of object
Now to implement this function into our collision detection lets create a new event. Which one should we choose well, the best one for collision is:
Code:
While something is true
If you go back and look at your old thread you will notice that instead I used the "When something becomes true," instead of the aforementioned event. I did this mainly because you can only die
once, but you can walk into a building all you want.
So in your event bar you should have something similar to:
Code:
While <NONE> is true
Begin:<NONE>
During:<NONE>
End:<NONE>
Okay know for this example I am going to use two cubes. So go to first cube's functions and find the one similar to the function above. Click and drag it onto the very first <NONE> in our event; two popup menus will appear, one being about distance say one meter and the other being about which object you want to collide with,cube2. You should have:
Code:
While cube is within 1 meter of cube2 is true
Begin:<NONE>
During:<NONE>
End:<NONE>
Almost done!
Okay now when you hit something such as a wall, what do you do? You move backward, and this is exactly what we are going to do.
In the during section of your event you are going to add an event from the cubes methods, more specifically the move method. So move your method into the during and set the direction to backward, and you are done!
If you still don't understand here is the above coding in an actual world. Th only exceptions are that I added a moving event and replaced the move method with the move at speed method, mainly because it runs smoother.
Oh and as a side note sorry I did not finish my post on your thread I have been kind of busy lately; I will get to it....eventually.