I'm making a ESDF-based movement system, where s and f are turning (as opposed to moving sideways). E and D will be accelerating forwards and backwards, and I want s and f to, without stopping the unit or otherwise impeding movement, slightly shift its movement by a few degrees and continue doing it while they're held down. It somewhat works using a simple on-keypress direction-change, but that both requires repeated presses and stops the unit's movement. If I add a while-loop (while key is pressed), it seems unable to execute the function and returns an error. Help?
EDIT: Also, is there any way to detect mouse position? I'm trying to make the hellion's turret face the mouse, but the only mouse-related anything I can find is {point, x, y, etc} clicked.
Use the KeyUP and KeyDOWN events to set a bool value to true or false, representing the state of the key. Write a trigger that occurs every 0.0 game seconds that turns the unit a slight angle if that boolean value is true.
Okay, I tried it out, got it somewhat-working. E accelerates, d decelerates, s turns left and f turns right. I have several problems: While turning left (and only left, not right), it's detecting "stop" commands and if you hold it for more than approximately two seconds the unit stays in one place and turns there. If you click repeatedly in smaller intervals, it works. When turning right, it goes fine for some time and suddenly stops turning at all, going in a straight line. At first I thought maybe degrees didn't wrap around, but there's no way Blizzard screwed that up.
Apart from these two problems, this is very choppy. It's annoying, and even if the above problems are fixed, unless it becomes less choppy it'll be neigh-unplayable. Does anyone have any advice on fixing it or have an example map to see how it should be done?
Additionally, I want to make acceleration and deceleration depend on terrain slope, so... is there any way to detect slope of terrain looking at the profile of the unit (so, the slope of the floor under the unit while looking at the unit from its side)?
Because I REALLY need the choppiness removed, here's the main trigger that brings everything together:
I had a few revelations while at school, here's what my solutions to my own problems are:
Remove the rotation of the unit in lieu of simply ordering the unit to stop choppiness and other such problems, and for the finding slope, have two variables that record the x, y and z information (points), and every cycle replace one with the other and the other one with current location. Then compare difference in Z and difference in square root of sum of squares of x and y of both points.
The other two problems, with not-turning and stopping in one place, stem from: The distance 40 being too far ahead, so when the unit gets to the edge of the map it's being ordered to move off the edge and it ignores the orders. Additionally, the S button is also the hotkey for "stop", which is what's screwing that up. Figured these out recently. How do I change hotkey for stop?
to change hotkeys simply go the the Buttons section of the data editor and find the stop button and change its hotkey from s to something else or blank.
I'm making a ESDF-based movement system, where s and f are turning (as opposed to moving sideways). E and D will be accelerating forwards and backwards, and I want s and f to, without stopping the unit or otherwise impeding movement, slightly shift its movement by a few degrees and continue doing it while they're held down. It somewhat works using a simple on-keypress direction-change, but that both requires repeated presses and stops the unit's movement. If I add a while-loop (while key is pressed), it seems unable to execute the function and returns an error. Help?
EDIT: Also, is there any way to detect mouse position? I'm trying to make the hellion's turret face the mouse, but the only mouse-related anything I can find is {point, x, y, etc} clicked.
@Centreri: Go
Use the KeyUP and KeyDOWN events to set a bool value to true or false, representing the state of the key. Write a trigger that occurs every 0.0 game seconds that turns the unit a slight angle if that boolean value is true.
Okay, I tried it out, got it somewhat-working. E accelerates, d decelerates, s turns left and f turns right. I have several problems: While turning left (and only left, not right), it's detecting "stop" commands and if you hold it for more than approximately two seconds the unit stays in one place and turns there. If you click repeatedly in smaller intervals, it works. When turning right, it goes fine for some time and suddenly stops turning at all, going in a straight line. At first I thought maybe degrees didn't wrap around, but there's no way Blizzard screwed that up.
Apart from these two problems, this is very choppy. It's annoying, and even if the above problems are fixed, unless it becomes less choppy it'll be neigh-unplayable. Does anyone have any advice on fixing it or have an example map to see how it should be done?
Additionally, I want to make acceleration and deceleration depend on terrain slope, so... is there any way to detect slope of terrain looking at the profile of the unit (so, the slope of the floor under the unit while looking at the unit from its side)?
Because I REALLY need the choppiness removed, here's the main trigger that brings everything together:
I'll be very, very grateful - this is a very frustrating problem.
May i asked if you managed to get your hellions turret to rotate? Through triggers?
Not yet, working on this for now.
I had a few revelations while at school, here's what my solutions to my own problems are:
Remove the rotation of the unit in lieu of simply ordering the unit to stop choppiness and other such problems, and for the finding slope, have two variables that record the x, y and z information (points), and every cycle replace one with the other and the other one with current location. Then compare difference in Z and difference in square root of sum of squares of x and y of both points.
The other two problems, with not-turning and stopping in one place, stem from: The distance 40 being too far ahead, so when the unit gets to the edge of the map it's being ordered to move off the edge and it ignores the orders. Additionally, the S button is also the hotkey for "stop", which is what's screwing that up. Figured these out recently. How do I change hotkey for stop?
to change hotkeys simply go the the Buttons section of the data editor and find the stop button and change its hotkey from s to something else or blank.
@Docablo: Go
Ah, thanks. Now, to work on the more complicated 3D portion of this. : /