• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to make a unit move using A,D or W buttons

Status
Not open for further replies.
Level 6
Joined
Feb 16, 2014
Messages
193
I want to make unit walk using these buttons:
When a players presses "A" then the unit walks left,when its "D" then the unit walks right.And i also want a unit to jump when a player presses "W".How do i do that? :ogre_rage:
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
The only way is to give the unit hidden abilities with these hotkeys and to detect the casting of those abilities.

There is no way known to detect a release of these buttons.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
I thought there are systems out there. If you talk about arrows, then it'd be normal events with arrows responding, if you ever talk about letters W.S.D.... Then you talk about abilities.

Some pre-links :
3rd Person Camera movement
Complexe TopDown WASD Movement
Arrow Key Tutorial

First, you create 4 abilities ( Up - Down - Right - Left ), based on channel ( Change the string order and everything between each. Make them instant and visible. Remove all allowed targets. Then let's go to triggers :
NOTE : You should disable unit's movement speed to not go out of control. Set it to 0
Here is an example for moving around. (Remove Leaks yourself :D)
Lel it likz sew mush
  • Events
    • Unit - A Unit starts the effect of an ability
  • Conditions
    • (Ability Being Cast) Equal To Up ( Channel W)
  • Actions
    • Set Caster = (Triggering Unit)
    • Set CPNumber = (Owner of (Triggering Unit))
    • Player Group - Add (Triggering Player) to (Up-Movers)
    • Unit Group - Add Caster to Up-movers_Units
  • Events
    • Time - Every 0.05 seconds
  • Conditions
  • Actions
    • Player Group - Pick Every Player in Up_Movers
      • Loop
        • Unit Group - Pick Every Unnit in Up_Movers_Units
          • Loop
            • Set Up_Mover = (Picked Unit)
            • Set Up_Mover_Point = (Position of Up_Mover)
            • Set Up_Mover_Next = (Up_Mover_Point offset by 30 towards 90 angle)
            • Unit - Move Up_Mover to Up_Mover_Next
            • Custom script: call SetUnitAnimationByIndex(udg_Up_Mover, 5)

Let's go to the jump :
Pre link : Jump Tutorial MPI/MUI
Out-link Jump System


Okay, any jump needs a parabola maths formula, which I really, suck in it.

I won't give any example for it but of course just change the event of any of previous systems. It'll be smooth trust me ;)

I made a 2D Parabola Jump System , if your map is 2-Dimensional I can send you my Sample Platformer map.

Greetings...
 
Level 6
Joined
Feb 16, 2014
Messages
193
I thought there are systems out there. If you talk about arrows, then it'd be normal events with arrows responding, if you ever talk about letters W.S.D.... Then you talk about abilities.

Some pre-links :
3rd Person Camera movement
Complexe TopDown WASD Movement
Arrow Key Tutorial

First, you create 4 abilities ( Up - Down - Right - Left ), based on channel ( Change the string order and everything between each. Make them instant and visible. Remove all allowed targets. Then let's go to triggers :
NOTE : You should disable unit's movement speed to not go out of control. Set it to 0
Here is an example for moving around. (Remove Leaks yourself :D)
Lel it likz sew mush
  • Events
    • Unit - A Unit starts the effect of an ability
  • Conditions
    • (Ability Being Cast) Equal To Up ( Channel W)
  • Actions
    • Set Caster = (Triggering Unit)
    • Set CPNumber = (Owner of (Triggering Unit))
    • Player Group - Add (Triggering Player) to (Up-Movers)
    • Unit Group - Add Caster to Up-movers_Units
  • Events
    • Time - Every 0.05 seconds
  • Conditions
  • Actions
    • Player Group - Pick Every Player in Up_Movers
      • Loop
        • Unit Group - Pick Every Unnit in Up_Movers_Units
          • Loop
            • Set Up_Mover = (Picked Unit)
            • Set Up_Mover_Point = (Position of Up_Mover)
            • Set Up_Mover_Next = (Up_Mover_Point offset by 30 towards 90 angle)
            • Unit - Move Up_Mover to Up_Mover_Next
            • Custom script: call SetUnitAnimationByIndex(udg_Up_Mover, 5)

Let's go to the jump :
Pre link : Jump Tutorial MPI/MUI
Out-link Jump System


Okay, any jump needs a parabola maths formula, which I really, suck in it.

I won't give any example for it but of course just change the event of any of previous systems. It'll be smooth trust me ;)

I made a 2D Parabola Jump System , if your map is 2-Dimensional I can send you my Sample Platformer map.

Greetings...
Well my map is going to be a side scroller.But another question,how do i make the camera focus on the side of the player's unit?
 
Level 6
Joined
Feb 16, 2014
Messages
193
so you want third person camera, huh? Right now I'm thinking about an invisible dummy that walks with your unit with some offset, with camera locked ;d

edit: look what i found ;d

  • Camera - Lock camera target for Player 1 (Red) to (Triggering unit), offset by (0.00, 0.00) using Default rotation

Um, I already tried that, didn't work :(
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Focus ? On side of unit?
Regarding to what I understood from you :

1- Focus :

There are two ways to focus a camera on a unit

  • Camera - Lock camera target for Player 1 (Red) to 'Your Unit' ... == Single Trigger ==

  • Events
    • Time - Every 0.3 seconds of game time
  • Conditions
  • Actions
    • Set CameraFocusPoint = ( Position of 'Your Unit )
    • Camera - Move Player 1's camera to CameraFocusPoint in 0.00 seconds
    • Custom script: call RemoveLocation(udg_CameraFocusPoint)
2- Focusing from the SIDE of the unit :


I really didn't understand good your question, but you surely mean to change camera angle

In the previous trigger add this :
  • Camera - Change Player 1's camera's Angle Of Attack to 125 ° over 0.00 seconds === To make 3rd person view ==
  • Camera - Change Player 1's camera's Rotation to (Facing of 'Your Unit' - 90 or 45) over 0.00 seconds === to make a side 3rd person view ==

P.S : Just play with the camera field options you'll eventually get your desired camera.
 
Status
Not open for further replies.
Top