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.
Locations alone could be used to track the unit's movement. Example
here.
None.
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.
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.
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.
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.
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.
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.
I have no idea. Maybe vultures with speed upgrade, but I haven't tested that.
None.
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?"