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.
[10:34 am]
NudeRaider -- SEN doesn't rely on spammers initiate its sleep cycle. It hat fully automated rest and clean-up phases. Please understand that this is necessary for the smooth operation of the site. Thank you.
[03:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[2024-5-17. : 6:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[2024-5-17. : 5:41 am]
Ultraviolet -- 🤔 so inf is in you?
[2024-5-17. : 4:57 am]
O)FaRTy1billion[MM] -- my name is mud
[2024-5-17. : 4:35 am]
Ultraviolet -- mud, meet my friend, the stick
[2024-5-16. : 10:07 pm]
lil-Inferno -- nah
[2024-5-16. : 8:36 pm]
Ultraviolet -- Inf, we've got a job for you. ASUS has been very naughty and we need our lil guy to go do their mom's to teach them if they fuck around, they gon' find out
[2024-5-16. : 5:25 pm]
NudeRaider -- there he is, right on time! Go UV! :D
[2024-5-16. : 5:24 pm]
lil-Inferno -- poopoo
Please log in to shout.


Members Online: 4jasminee571yc3, Roy, 6camilac933eM4