• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Key movement - strafe system

Status
Not open for further replies.
So as some of you know, I have a helicopter map. I am in the market for a trigger that allows you to move side to side while facing forward. This needs to happen while moving. Currently I can make it move side to side but the forward motion stops. My guess is that there is already a system that does this but my searches have come up empty. + rep to anyone who can find a system or write one that will permit this strafing movement.

  • Request for Advice
    • Event -
      • Player - User provides Legal_Ease with advice
    • Conditions -
      • Boolean - Advice equal to true
    • Actions -
      • Unit - Legal_Ease gives rep to User
 
Level 18
Joined
May 11, 2012
Messages
2,103
I think I'd be able to do it, but I have no WE here...
You can use boolean[] variables when you press (?) key and set that boolean[] to true, and when releases it set it to false. Have another periodic trigger that will move your unit if the boolean[] is true. Something like that, it might not be smooth but that's how I imagine doing it.

Use arrays if it has to be MPI
 
Level 18
Joined
May 11, 2012
Messages
2,103
Oh yeah, reminded me.

You could do exactly the same for the facing. Create 2 more booleans[] and (for example I press: A or D, set facing to ''curent facing + 2'' or something like that) do exactly the same like above.
 
I think I'd be able to do it, but I have no WE here...
You can use boolean[] variables when you press (?) key and set that boolean[] to true, and when releases it set it to false. Have another periodic trigger that will move your unit if the boolean[] is true. Something like that, it might not be smooth but that's how I imagine doing it.

Use arrays if it has to be MPI

Ya, I know how to do this, I already have a camera and lift system that work on this principle. But, its the "move" command that is problematic.

Oh, and use SetUnitX/Y so you don't interrupt the orders.

Here we go, this looks better :)

Ah why not ;)
If he wants to face the same point as use this.

Exactly!

I was hoping someone would write it out for me or point me to a system that already exists that uses this technique so that I can just copy it rather than spending another week of trial and error before I get it right. There's a lot going on in this flight system I'm making and this is a tricky one, but I feel like some one has done it before and that would help save me a bunch of time.

+rep all around!
 
No nothing works yet, but since no one found a link for me or wrote something, I'm going to try it out myself. I'll try to post something tonight whether it works or not. If something is solved I like to post the result because it might help someone else.

  • TTurn Right
    • Turn Right
      • Events
        • Time - Every 0.01 seconds of game time
      • Conditions
        • Right[1] Equal to 1
      • Actions
        • Set MoveRight = ((Position of Chopper[1]) offset by 2.00 towards ((Facing of Chopper[1]) - 90.00) degrees)
        • Set RealX = (X of MoveRight)
        • Set RealY = (Y of MoveRight)
        • Custom script: call SetUnitY(udg_Chopper[1], udg_RealY)
        • Custom script: call SetUnitX(udg_Chopper[1], udg_RealX)
Ok, this is starting to feel right, but it goes into a tailspin if you hold an arrow and move at the same time.
 
Last edited:
Looks like this thread contains more helpless Reply's than helpfull ones

Hahahaha, you guys are funny. But, look, you are all actually helping me quite a bit. Even though I did most of this on my own, the hints here and there and the collective knowledge keep me going. So thank you, I have more rep for you once I spread some around a bit. And I know what leaks, thanks, I don't need help with leaks. Once I get a working trigger I will be sure to clean it. For now I need to stop the chopper from spinning around in circles as it approaches it "move" destination when holding the "right arrow." See the facing angle sticks as what it was when its first held down [>] right arrow and as you approach the place you clicked on the map, the chopper breaks into a tailspin. Test Map - Choplifter 3D

  • Rotate Left
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
    • Actions
      • Set Left[1] = 1
  • Rotate Right off
    • Events
      • Player - Player 1 (Red) Releases the Right Arrow key
    • Conditions
    • Actions
      • Set Right[1] = 0
As you can see left is an integer variable which turns to one when pressed and 0 when released.


  • Set cam
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to |cff0066ccApache|r
        • Then - Actions
          • Set Chopper[1] = (Triggering unit)
          • Animation - Change Chopper[1]'s animation speed to 300.00% of its original speed
          • Wait 6.00 seconds
          • Trigger - Turn on Third Person Camera <gen>
        • Else - Actions
  • lift action
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set CLoc = (Position of Chopper[1])
      • Custom script: set udg_Real = GetLocationZ(udg_CLoc)
      • Destructible - Pick every destructible within 60.00 of CLoc and do (Actions)
        • Loop - Actions
          • Custom script: set udg_Real2 = GetDestructableOccluderHeight(udg_Dest)
      • Set TempHeight = (Real + Real2)
      • Animation - Change Chopper[1] flying height to ((Real(Height[1])) - TempHeight) at 0.00
      • Custom script: call RemoveLocation ( udg_CLoc )
Here's where I set the game cam and the unit variable for the chopper. I also included part of the lift system just for fun. It uses the up and down arrows with integer variables just like left and right.
  • Turn Right
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
      • Right[1] Equal to 1
    • Actions
      • Set MoveRight = ((Position of Chopper[1]) offset by 2.00 towards ((Facing of Chopper[1]) - 90.00) degrees)
      • Set RealX = (X of MoveRight)
      • Set RealY = (Y of MoveRight)
      • Custom script: call SetUnitY(udg_Chopper[1], udg_RealY)
      • Custom script: call SetUnitX(udg_Chopper[1], udg_RealX)
This is the final motion trigger the way it is now. Somehow it needs to update the facing angle to keep it face the destination if the chopper is issued the order "move" while the right arrow is being pressed. Otherwise as it move it starts to veer off and then spins before reaching its destination. I know one solution might be to create a non GUI movement system entirely, but I'm not that bold.
 
Last edited:
Well, someone suggested SetUnitX, But I think it was Doomlord on my last trigger question. Either way, this is not solved.

Someone asked me to post all the triggers, so I posted more and the test map.

I now have a sideways motion but it does not work with other commands like "move" and "attack." The purpose of the helicopter move system is to be able to do both at once. So move sideways while attacking or while moving forward. Currently, the chopper spins out of control when you try to move forward and to the side at the same time.
 
If your loop is with a very low time i don't think it will be able to receive orders normally

Hmmm, problem with that is that a higher loop time will make the motion jerky. I'll try .05 though and see if it helps.

[edit]
  • Turn Left
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • Left[1] Equal to 1
    • Actions
      • Set MoveRight = ((Position of Chopper[1]) offset by 7.00 towards ((Facing of Chopper[1]) + 90.00) degrees)
      • Set RealX = (X of MoveRight)
      • Set RealY = (Y of MoveRight)
      • Unit - Make Chopper[1] face (Target point of issued order) over 0.01 seconds
      • Custom script: call SetUnitY(udg_Chopper[1], udg_RealY)
      • Custom script: call SetUnitX(udg_Chopper[1], udg_RealX)
This fails. The only effect it has is to reduce the occurrences of the sideways motion which does avoid a tailspin but only by making it really jerk and slow. This makes it so that the motion isn't smooth enough to take it into a complete circle but it still starts to spin that way, it just doesn't make it into a full spin. I tried both with and without the facing angle adjustment added.
 
Anyway My suggestion is not to use waits, because that is a long wait time try to use counters.

Waits have nothing to do with the problem. I know waits are inaccurate, I know what leaks are, I know how to use counters and I know how to clean leaks. That "wait" is there for part of the intro sequence and has nothing to do with this issue. I don't need help with that. I have a specific problem. I need a specific solution.

The question is this -

What set of triggers will allow and unit to move side to side without interrupting orders and while keeping a forward facing orientation?

The SetUnitx,y almost works except the problem as noted at length above. Please see if you can answer this. +rep to you just for checking back in though. I appreciate that.
 
If player holds an arrow key (see trigger above) the chopper moves sideways while facing forward. This is good. BUT! When the player holds the arrow key and clicks the terrain - giving a "move" order - while holding the arrow key the chopper starts to stray from its path and then starts spinning in circles. Not good :(

This is happening because the setunit order places the triggering unit left or right 90 degrees from the current facing angle. But this changes as the chopper "moves" and as it approaches the chopper moves to the side and as the chopper moves to the side it moves away from its destination 90 degrees to the side. This causes it to spin around the destination point right before it actually makes it there. I can slow the side-to-side movement speed which reduces the effect but it still strays as it moves and it looks funny. Did you fly it in the test map?

spiral-of-theodorus.png


Picture the long green line as the distance to the target destination at the start.

Then see the line to the side. This is the side-ways motion from using the arrow key.

As the unit approaches the center, it starts to spin around it.

And what happens looks more like this.

logspiral.png
 
Last edited:
Status
Not open for further replies.
Top