Collision, how does this work
Author |
Message |
Quakerstate98
|
Posted: Mon Jun 19, 2006 12:16 pm Post subject: Collision, how does this work |
|
|
How does collision work- |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
|
|
|
|
Bored
|
Posted: Mon Jun 19, 2006 1:23 pm Post subject: (No subject) |
|
|
Well since this is a very general question I'll give you a very general answer. Collision works by calcualtion if to ingame objects are found to be touching and if so then it does something such as damage a character, move the character backwards, change levels, etc. Thers' many ways to go about this and whole tutorials on it. You could simply check the area infront of a character with whatdot colour to see if its a wall or you could go all the way to actually using formulas for intersection of lines with lines, or even conics with lines. What way to go about it is all dependant on skill level, knowledge, effort your willing to put into it, time available, the games setup, the shape of objects, and importance of accuracy. |
|
|
|
|
|
r.3volved
|
Posted: Mon Jun 19, 2006 2:50 pm Post subject: (No subject) |
|
|
in a 2 dimentional space, collision detection is easily done by calculating overlap of 2 images/objects.
so if object1.rightside() > object2.leftside() and object1.leftside() < object2.rightside() then you have an overlap on the x axis
same should be done with top and bottoms to make sure the object isn't simple passing by the other on the x axis, but is infact overlapping it.
in a 3 dimentional space you're simply dealing with 3 axis instead of 2 |
|
|
|
|
|
Bored
|
Posted: Mon Jun 19, 2006 4:13 pm Post subject: (No subject) |
|
|
Yes but you'r forgetting, not all objects are square, you may have overlapping pictures but the objects themselves may not be overlapping. That's why there's oval collision which more often produces a closer result then sqaure collision. |
|
|
|
|
|
r.3volved
|
Posted: Mon Jun 19, 2006 5:14 pm Post subject: (No subject) |
|
|
It was a generalization....
he doesn't even know how to induce collision detection in the first place, and you gotta learn to walk before you learn to run (someone shoulda told you sooner) |
|
|
|
|
|
Bored
|
Posted: Mon Jun 19, 2006 8:56 pm Post subject: (No subject) |
|
|
Yes but his question was how does collision WORK, not how can I implement collision, so in the end it's much better to give him the general idea behind collision, then have hime READ the tutorials on collision, or figure it out on his own. |
|
|
|
|
|
aldreneo
|
Posted: Tue Jun 20, 2006 10:49 am Post subject: (No subject) |
|
|
It works like this:
If player is within 10 pixels inside block then move player -10 pixels outside block |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Bored
|
Posted: Tue Jun 20, 2006 10:56 am Post subject: (No subject) |
|
|
That's not how collision works, that a method of dealing with collision. The simplest way to sum it up is collision works by deciding whether to objects are touching and if so it deals with it in whatever manner needed. Just becuase an object is 10 pixels inside another dosen't nesecarily mean you want to move it back 10 pixels. |
|
|
|
|
|
|
|