Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: Way to detect unit position?
Way to detect unit position?
Feb 1 2010, 5:43 am
By: stickynote  

Feb 1 2010, 5:43 am stickynote Post #1



Aight. I'm trying to figure out which direction a unit is facing. Right now, I'm using a mobile grid to detect where it's last position was relative to it's current position to determine that. It works, but it causes unt slow down, and the movement gets a little jerky due to mobile grid creation. It's just one unit I need to detect.



None.

Feb 1 2010, 6:15 am Kenoli Post #2



Locations alone could be used to track the unit's movement. Example here.



None.

Feb 1 2010, 10:35 am JaFF Post #3



Depends on how accurate you want it to be. Not a very accurate, but a very simple solution would be to use a basic coordinate detection system.



None.

Feb 1 2010, 5:31 pm CecilSunkure Post #4



Yeah, I think you would just have to compare the previous coordinate with the current one, and then guess the unit's direction off of that.



None.

Feb 1 2010, 6:06 pm JaFF Post #5



Quote from CecilSunkure
Yeah, I think you would just have to compare the previous coordinate with the current one, and then guess the unit's direction off of that.
Yup. I should elaborate a bit. For better results, constantly scan the unit's coordinates and record the last N positions. The greater the unit's speed, the less positions you have to record. Having a finer coordinate definition would help, too. Once you have the data, ignore everything before an acceleration change. Then subtract the current position from the last applicable one in the storage. This gives you the approximate vector of direction. You could simplify this and just compare the last observation and the current position, but it will give you less accurate results.

This is all purely theoretical; it might or might not be useful or practical for your case. If you're seriously considering using something like this, you might as well consider doing a pixel-perfect coordinate detection, because it will make this process almost unnecessary and give you loads of other benefits from the pixel-perfect coordinates you'll have. Then again, the pixel-perfect coordinate system might not be practical, too. So yeah, you have to decide what's better.



None.

Feb 1 2010, 6:21 pm ImagoDeo Post #6



http://www.staredit.net/topic/8993/

http://www.staredit.net/topic/9155/ uses this system.



None.

Feb 2 2010, 2:20 am stickynote Post #7



Ok. I got it to work. I don't know if this is the same syste kenoli used, but I'll just share my findings.

As stated in the topic linked to in Kenoli's post, locations do not center exactly on a unit since the smallest unit is 1 pixel. I used 4 inverted locations. 1 that was the width of the unit, 1 that was the height of the unit, 1 that was the unit's width minus 1 pixel, and the last was the height of the unit minus 1 pixel.

All 4 locations are centered on it, but the two that are 1 pixel smaller are centered at the top and left of the unit, with 1 side not toughing the unit edge.

So, if the unit leaves both width locations, it has moved right. If it has left the larger location but is still in the smaller one, it has moved left. It is the same with the heght locations except for down and up, respectively.
Hope that was understandable.

Post has been edited 1 time(s), last time on Feb 2 2010, 2:23 am by stickynote. Reason: Making it easier to read



None.

Feb 2 2010, 4:50 pm Kaias Post #8



Quote from stickynote
Ok. I got it to work. I don't know if this is the same syste kenoli used, but I'll just share my findings.

As stated in the topic linked to in Kenoli's post, locations do not center exactly on a unit since the smallest unit is 1 pixel. I used 4 inverted locations. 1 that was the width of the unit, 1 that was the height of the unit, 1 that was the unit's width minus 1 pixel, and the last was the height of the unit minus 1 pixel.

All 4 locations are centered on it, but the two that are 1 pixel smaller are centered at the top and left of the unit, with 1 side not toughing the unit edge.

So, if the unit leaves both width locations, it has moved right. If it has left the larger location but is still in the smaller one, it has moved left. It is the same with the heght locations except for down and up, respectively.
Hope that was understandable.
Indeed that is Kenoli's method. It's quite ingenious.



None.

Feb 2 2010, 5:52 pm CecilSunkure Post #9



Oh? It will always center to the top left, since the smallest increment of distance is 1 pixel? Referring to the two smaller locations. No units move too fast for this to not work?



None.

Feb 3 2010, 3:35 am stickynote Post #10



I have no idea. Maybe vultures with speed upgrade, but I haven't tested that.



None.

Feb 3 2010, 1:29 pm rockz Post #11

ᴄʜᴇᴇsᴇ ɪᴛ!

Quote from rockz
Here's my theoretical list: (* indicates speed upgrade).
Nuclear Missile
Scarab
Spider Mine
Interceptor
Vulture*
Zergling*
Ultralisk*
Scourge
Broodling
Zealot*
Marine*
Firebat*
Infested Terran
Hydralisk*
Zergling
Dragoon
Dark Templar (Unit)
Infested Kerrigan
Dark Templar (Hero)
Zealot
Civilian
Firebat
Ghost
Sarah Kerrigan
Hydralisk




"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:53 pm]
Oh_Man -- https://youtu.be/MHOZptE-_-c are yall seeing this map? it's insane
[2024-5-04. : 1:05 am]
Vrael -- I won't stand for people going around saying things like im not a total madman
[2024-5-04. : 1:05 am]
Vrael -- that's better
[2024-5-04. : 12:39 am]
NudeRaider -- can confirm, Vrael is a total madman
[2024-5-03. : 10:18 pm]
Vrael -- who says I'm not a total madman?
[2024-5-03. : 2:26 pm]
UndeadStar -- Vrael, since the ad messages get removed, you look like a total madman for someone that come late
[2024-5-02. : 1:19 pm]
Vrael -- IM GONNA MANUFACTURE SOME SPORTBALL EQUIPMENT WHERE THE SUN DONT SHINE BOY
[2024-5-02. : 1:35 am]
Ultraviolet -- Vrael
Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
Gonna put deez sportballs in your mouth
[2024-5-01. : 1:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
Please log in to shout.


Members Online: Excalibur, Roy