• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Advanced Arrow Key (More Than 8 Angles)

Status
Not open for further replies.
Level 22
Joined
Jul 25, 2009
Messages
3,091
Okay, so I am making an arrow key movement system. How it's supposed to work, is when you combine left and right with forward it changes the angle slightly as you are moving. Like driving a car... Up key is gas, left and right are steering.

It turned out dismal, the only thing that works is the move forward command. Help.
The left and right key triggers are the same, just with different variables and arrow keys ofc, posting both of them is unnecessary. Tell me if I should post the forward actions.

  • Left Key
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
      • Player - Player 2 (Blue) Presses the Left Arrow key
      • Player - Player 3 (Teal) Presses the Left Arrow key
      • Player - Player 4 (Purple) Presses the Left Arrow key
      • Player - Player 5 (Yellow) Presses the Left Arrow key
      • Player - Player 6 (Orange) Presses the Left Arrow key
      • Player - Player 7 (Green) Presses the Left Arrow key
      • Player - Player 8 (Pink) Presses the Left Arrow key
      • Player - Player 9 (Gray) Presses the Left Arrow key
      • Player - Player 10 (Light Blue) Presses the Left Arrow key
      • Player - Player 11 (Dark Green) Presses the Left Arrow key
      • Player - Player 12 (Brown) Presses the Left Arrow key
    • Conditions
    • Actions
      • Player Group - Add (Triggering player) to XY_LeftMovingGroup
      • Set XY_MovementLeft[(Player number of (Triggering player))] = True
  • Left Key Released
    • Events
      • Player - Player 1 (Red) Releases the Left Arrow key
      • Player - Player 2 (Blue) Releases the Left Arrow key
      • Player - Player 3 (Teal) Releases the Left Arrow key
      • Player - Player 4 (Purple) Releases the Left Arrow key
      • Player - Player 5 (Yellow) Releases the Left Arrow key
      • Player - Player 6 (Orange) Releases the Left Arrow key
      • Player - Player 7 (Green) Releases the Left Arrow key
      • Player - Player 8 (Pink) Releases the Left Arrow key
      • Player - Player 9 (Gray) Releases the Left Arrow key
      • Player - Player 10 (Light Blue) Releases the Left Arrow key
      • Player - Player 11 (Dark Green) Releases the Left Arrow key
      • Player - Player 12 (Brown) Releases the Left Arrow key
    • Conditions
    • Actions
      • Player Group - Remove (Triggering player) from XY_LeftMovingGroup
      • Set XY_MovementLeft[(Player number of (Triggering player))] = False
  • Unit Is Moving Left
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in XY_LeftMovingGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • XY_MovementLeft[(Player number of (Picked player))] Equal to True
            • Then - Actions
              • Set XY_TargetPoint[(Player number of (Picked player))] = (XY_TargetPoint[(Player number of (Picked player))] offset by 75.00 towards ((Facing of XY_ControlledUnit[(Player number of (Picked player))]) + 10.00) degrees)
            • Else - Actions
 
Where is the action to actually move the unit?
also, use this to prevent leaks:
  • Set I = (Player number of (Picked player))
  • Set Point1 = (Position of XY_ControlledUnit[I])
  • Set Point2 = (Point1 offset by 75.00 towards (...))
  • Unit - Move XY_ControlledUnit[I] to Point2
  • Custom script: call RemoveLocation (udg_Point1)
  • Custom script: call RemoveLocation (udg_Point2)
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
Where is the action to actually move the unit?
also, use this to prevent leaks:
  • Set I = (Player number of (Picked player))
  • Set Point1 = (Position of XY_ControlledUnit[I])
  • Set Point2 = (Point1 offset by 75.00 towards (...))
  • Unit - Move XY_ControlledUnit[I] to Point2
  • Custom script: call RemoveLocation (udg_Point1)
  • Custom script: call RemoveLocation (udg_Point2)

I know there are things in here that don't quite make sense, and aren't efficient, but that is not my concern at the moment I just want to get the system working first. The GUI shown below works properly, the GUI in the first post does not. Thank you for your rapid response.

  • Up Key
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
      • Player - Player 2 (Blue) Presses the Up Arrow key
      • Player - Player 3 (Teal) Presses the Up Arrow key
      • Player - Player 4 (Purple) Presses the Up Arrow key
      • Player - Player 5 (Yellow) Presses the Up Arrow key
      • Player - Player 6 (Orange) Presses the Up Arrow key
      • Player - Player 7 (Green) Presses the Up Arrow key
      • Player - Player 8 (Pink) Presses the Up Arrow key
      • Player - Player 9 (Gray) Presses the Up Arrow key
      • Player - Player 10 (Light Blue) Presses the Up Arrow key
      • Player - Player 11 (Dark Green) Presses the Up Arrow key
      • Player - Player 12 (Brown) Presses the Up Arrow key
    • Conditions
    • Actions
      • Player Group - Add (Triggering player) to XY_UpMovingGroup
      • Set XY_TargetPoint[(Player number of (Triggering player))] = ((Position of XY_ControlledUnit[(Player number of (Triggering player))]) offset by 1000000000.00 towards (Facing of XY_ControlledUnit[(Player number of (Triggering player))]) degrees)
      • Set XY_MovementFoward[(Player number of (Triggering player))] = True
      • Unit - Order XY_ControlledUnit[(Player number of (Triggering player))] to Move To XY_TargetPoint[(Player number of (Triggering player))]
  • Up Key Released
    • Events
      • Player - Player 1 (Red) Releases the Up Arrow key
      • Player - Player 2 (Blue) Releases the Up Arrow key
      • Player - Player 3 (Teal) Releases the Up Arrow key
      • Player - Player 4 (Purple) Releases the Up Arrow key
      • Player - Player 5 (Yellow) Releases the Up Arrow key
      • Player - Player 6 (Orange) Releases the Up Arrow key
      • Player - Player 7 (Green) Releases the Up Arrow key
      • Player - Player 8 (Pink) Releases the Up Arrow key
      • Player - Player 9 (Gray) Releases the Up Arrow key
      • Player - Player 10 (Light Blue) Releases the Up Arrow key
      • Player - Player 11 (Dark Green) Releases the Up Arrow key
      • Player - Player 12 (Brown) Releases the Up Arrow key
    • Conditions
    • Actions
      • Player Group - Remove (Triggering player) from XY_UpMovingGroup
      • Set XY_MovementFoward[(Player number of (Triggering player))] = False
      • Unit - Order XY_ControlledUnit[(Player number of (Triggering player))] to Stop
  • Unit Is Moving Foward
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in XY_UpMovingGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • XY_MovementFoward[(Player number of (Picked player))] Equal to True
            • Then - Actions
              • Unit - Order XY_ControlledUnit[(Player number of (Picked player))] to Move To XY_TargetPoint[(Player number of (Picked player))]
            • Else - Actions
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
a) Don't use booleans, just adding the player in the group will confirm the direction in the loop trigger.

b) Don't constantly order it, use "Unit - Move unit" and use a periodic event of "0.03 - 0.05" for that.

c) Still, your "Up" triggers have the moving orders, while the "Left" don't.

A: Already knew that. It doesn't seem like you are reading any of my responses.

B: More specific please

C: You really should read my entire post dude, the first one. Up is gas, while right and left are steering, like a car, it does say "More than 8 angles).
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
Use two separate variables, one that will have the position of the controlled unit and the other one that sets the offset point. Use that offset point as a reference to the other trigger. This trigger always makes your unit to end up in the center of playable map area, doesn't it?

No, they just wander aimlessly, so much so that I don't know the problem, the only command they obey correctly is to move forward. An actual example of the GUI would be nice if you have the time.

What I'm trying to do, is basically make a system for driving. Up = Forward. Left = Steer Left. Right = Steer Right. Don't need anything down yet.
 
Status
Not open for further replies.
Top