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.
[09:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
[07:56 pm]
Ultraviolet -- NudeRaider
NudeRaider shouted: "War nie wirklich weg" 🎵
sing it brother
[06:24 pm]
NudeRaider -- "War nie wirklich weg" 🎵
[03:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[2024-4-27. : 1:53 am]
Ultraviolet -- :lol:
[2024-4-26. : 6:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[2024-4-26. : 6:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[2024-4-26. : 6:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[2024-4-26. : 6:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[2024-4-26. : 6:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
Please log in to shout.


Members Online: jun3hong