Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: Directional Collision Detection
Directional Collision Detection
Aug 7 2011, 3:09 am
By: Sacrieur  

Aug 7 2011, 3:09 am Sacrieur Post #1

Still Napping

Traditional collision detection can be done with a single location by simply overlapping a location over a unit. However, detecting where the collision occurred is more difficult. The system is made possible with use of skewed locations. Four different locations put a buffer around a unit and can detect a collision in any one of four cardinal directions.

There is a limitation: inverse logic must be used, so a collision on any two opposite sides at the same time will confuse the system. The logic is simple, however.

A: the unit is in the skewed location
B: the unit is not in the non-skewed location

If A and not B, then the unit is above or to the right.
If B, then the unit is down or to the left.

Since the non-skewed location hangs over both sides of the unit, SC will detect a collision regardless of the side. However, by adding the inverse of the second condition (not B), which side the collision took place on can be determined. But in solving this problem, we create another: if a collision occurs on both sides of the unit, the system will not detect the non-skewed direction. Fortunately, Aristocrat presented a solution:

If there are at least two B, but only one A, then then there is a collision on both sides.

While this solves the problem, it is not a true fix, since adding another A would invalidate the triggers. Fixing this with the same method would be invalidated by three As, and so on.

---

The uploaded map demonstrates this system.

Attachments:
DCD.scm
Hits: 16 Size: 39.12kb

Post has been edited 5 time(s), last time on Aug 20 2011, 7:14 am by Sacrieur.



None.

Aug 7 2011, 3:14 am TiKels Post #2



"Shifted locations" is already a term for a location that is bigger than the map in at least one dimension, usually 2x the size of the map. Also interesting application and use of the odd sized location thing.

You have to use 4 locations but there are two ways of doing it. Let's say this is a pixel grid and there is a unit that is 1 pixel large.
Code
123
456
789

Location 1 would encompass 5 and 6, location 2 would encompass 4 and 5, location 3 would encompass 2 5 and 8, and location 4 would encompass all of the squares. If a unit enters location 4 he has collided. You then detect which sides he has hit. I think this would be the ideal way of doing it since you only need 1 trigger to detect if they collide, but I didn't bother to look at your map to see if this is what you did.

Post has been edited 1 time(s), last time on Aug 7 2011, 3:22 am by TiKels.



"If a topic that clearly interest noone needs to be closed to underline the "we don't want this here" message, is up to debate."

-NudeRaider

Aug 7 2011, 3:18 am Sacrieur Post #3

Still Napping

Calling them skewed locations now.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[11:29 pm]
Vrael -- idk what I did but I like triple-posted in SD sorry
[02:45 pm]
NudeRaider -- Oh_Man
Oh_Man shouted: have i ever told u guys my SC2 pro-gamer story
how many GSL titles?
[2026-7-27. : 10:41 am]
ManCubuS -- Seems like something's broken regarding the site then. Sadge...
[2026-7-27. : 7:36 am]
Oh_Man -- have i ever told u guys my SC2 pro-gamer story
[2026-7-26. : 11:30 pm]
Ultraviolet -- That's strange, it looks like you targeted the base image file (sometimes people make the mistake of just using the imgur page link which doesn't work for embedding) but it still didn't work it sounds like.
[2026-7-26. : 3:34 pm]
ManCubuS -- Used : " [img=https://i.imgur.com/gpOjTuD.jpeg] "
[2026-7-26. : 3:28 pm]
ManCubuS -- Even tried with imgur, doesn't attach.
[2026-7-26. : 3:14 pm]
ManCubuS -- I should try a workaround, thanks! Sadly imgur is blocked in my country for some unknown reason.
[2026-7-26. : 3:05 pm]
NudeRaider -- I think SEN has trouble with https or hotlinking is forbidden. It certainly is nothing about the size, it just fails to get any size. You can get it working if you use imgur and include the actual image link for the img tag. Like this: [img=https://i.imgur.com/ddYqXZa.jpeg]
[2026-7-26. : 11:15 am]
ManCubuS -- Hey fellas! Anyone knows why when I try to upload an image it says "failed to get image size"? I even tried making it so small. Imgur isn't working here and I tried postimg no luck.
Please log in to shout.


Members Online: Symmetry