Posting my WASD Library here. It works for any camera view and only weighs 11kb. It only deals with WASD, it does nothing with mouselook etc or any other function. It's very simple to use, there are 3 public functions you'll want to plug into your code.
There are no timers and the movement is completely smooth. The BNet lag associated with using WASD is still associated, as it inherently will be with any method you use.
Not necessarily. Not if instead of actually using WASD, you use spells with WASD as hotkeys and listen to those. ;)
Not really useful: you can't catch the "key up" event, you have to have a unit selected, there might be problem with hitting 2 keys simultaneously.
And of course you can only catch a couple of the keyboard keys. Most special keys can't be hotkey-ed.
How would I make it turn based on current direction. (As in D always turns it right of where it's currently going)
And also how do I make a key to make it stop (faster than letting go of the keys)
And if possible a way to make it turn less rapidly (or even better, make it slide/drift) when it turns. Like a car.
@rrowland: Go i dont have those action WASD KeyDown Check(int Player, key 'Key Pressed')
Place this in the map's "Key Down - Any Player - Any Key" trigger.
WASD KeyUp Check(int Player, key 'Key Pressed')
Place this in the map's "Key Up - Any Player - Any Key" trigger.
WASD Set Controlled Unit(int Player, unit Unit)
Use this to set which unit a player is controlling with WASD.
Have you properly imported the library into your map? You have to go into the Trigger Editor, right click into the top left library window, and then Library -> Import Library.
If you have done that also remember to change the Library ID, you can do that by right clicking the library (the "WASD" folder) and then go to Library -> Change Library ID or something like that.
If you have done that too the only problem that I could think of is that you read the instructions wrong/are searching in the wrong menus. The way you would set this library up is to create a trigger with the event "Key pressed". Then set the event value to either "Up" or "Down" and double click the actions field to create a new action. Search for "WASD" and choose the action that matches the event. The "WASD Set Controlled Unit" action should be used in a trigger with the "Map Initialization" event.
My first post here is gonna be a bit of gravedigging, but I am having trouble figuring out how to use this WASD method to allow units to strafe. Basically, I want to use this library or something similar but have the A and D key strafe the unit to the left or right, but have the unit continue to face the direction of the player's camera.
EDIT: OK, so I know what I need to do, but not sure how to do it. I want to change this bit of code so that it instead of ordering the unit to move in the direction based on the key press and camera angle etc. it will just simply MOVE the unit a la "Move Unit Array Instantly" I'd be grateful for any help.
Posting my WASD Library here. It works for any camera view and only weighs 11kb. It only deals with WASD, it does nothing with mouselook etc or any other function. It's very simple to use, there are 3 public functions you'll want to plug into your code.
The main asset page is here: http://www.sc2mapster.com/assets/wasd-library-8-directional/
And you can download it here: http://www.sc2mapster.com/assets/wasd-library-8-directional/files/1-wasd-movement-library-v1-1/
Important: After importing you must change the library ID to ‘WASD’.
Public Functions:
WASD KeyDown Check(int Player, key 'Key Pressed')
Place this in the map's "Key Down - Any Player - Any Key" trigger.
WASD KeyUp Check(int Player, key 'Key Pressed')
Place this in the map's "Key Up - Any Player - Any Key" trigger.
WASD Set Controlled Unit(int Player, unit Unit)
Use this to set which unit a player is controlling with WASD.
Lagg free ? Smooth ?
wow, this makes making wasd movement very simple, thanks!
There are no timers and the movement is completely smooth. The BNet lag associated with using WASD is still associated, as it inherently will be with any method you use.
Not necessarily. Not if instead of actually using WASD, you use spells with WASD as hotkeys and listen to those. ;)
Not really useful: you can't catch the "key up" event, you have to have a unit selected, there might be problem with hitting 2 keys simultaneously.
And of course you can only catch a couple of the keyboard keys. Most special keys can't be hotkey-ed.
How would I make it turn based on current direction. (As in D always turns it right of where it's currently going) And also how do I make a key to make it stop (faster than letting go of the keys)
And if possible a way to make it turn less rapidly (or even better, make it slide/drift) when it turns. Like a car.
@ The first part:
Just change X to whatever you want to it turn by. Others, I don't really know. I would assume it would involve canceling the command, first of all.
@rrowland: Go i dont have those action WASD KeyDown Check(int Player, key 'Key Pressed') Place this in the map's "Key Down - Any Player - Any Key" trigger.
WASD KeyUp Check(int Player, key 'Key Pressed') Place this in the map's "Key Up - Any Player - Any Key" trigger.
WASD Set Controlled Unit(int Player, unit Unit) Use this to set which unit a player is controlling with WASD.
Have you properly imported the library into your map? You have to go into the Trigger Editor, right click into the top left library window, and then Library -> Import Library.
If you have done that also remember to change the Library ID, you can do that by right clicking the library (the "WASD" folder) and then go to Library -> Change Library ID or something like that.
If you have done that too the only problem that I could think of is that you read the instructions wrong/are searching in the wrong menus. The way you would set this library up is to create a trigger with the event "Key pressed". Then set the event value to either "Up" or "Down" and double click the actions field to create a new action. Search for "WASD" and choose the action that matches the event. The "WASD Set Controlled Unit" action should be used in a trigger with the "Map Initialization" event.
My first post here is gonna be a bit of gravedigging, but I am having trouble figuring out how to use this WASD method to allow units to strafe. Basically, I want to use this library or something similar but have the A and D key strafe the unit to the left or right, but have the unit continue to face the direction of the player's camera.
EDIT: OK, so I know what I need to do, but not sure how to do it. I want to change this bit of code so that it instead of ordering the unit to move in the direction based on the key press and camera angle etc. it will just simply MOVE the unit a la "Move Unit Array Instantly" I'd be grateful for any help.
lv_targetUnit = libWASD_gv_controlledUnits[lp_player]; while (libWASD_gv_wASDState[lp_player] != 0x0000) { UnitIssueOrder( lv_targetUnit, OrderTargetingPoint( AbilityCommand("move", 0), PointWithOffsetPolar(UnitGetPosition(lv_targetUnit), 1.2, libWASD_gf_GetWASDAngle(lp_player) + CameraGetYaw(lp_player)) ), c_orderQueueReplace ); Wait(0.0, c_timeGame); }
EDIT 2: Solved. Not sure what happened but i redid the whole thing and the problem has vanished. weird.