• 🏆 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!

Key Movement

Status
Not open for further replies.
Level 6
Joined
May 1, 2009
Messages
156
Hi

Could someone show me how to do movement with a single marine with using the arrow keys except not first person movement.
It's a set camera and so I need down to make him go down, up go up, left go left, right go right.



\ | /
-- -- <--- Movement
/ | \

And if anyone knows how to do left and right make him go NorthWest angled movement.
 
Level 10
Joined
Jul 22, 2007
Messages
261
pretty simple you make a trigger for each key for when it goes down it sets a Boolean to true and when you lift it up it sets it to false, then you have a trigger that runs every half second with an if statement ordering the unit to go up if W is pushed or north east if W and D are down
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You have a perodic trigger which moves him to his current location + x offset and y offset. This trigger should use game time
When left is pressed, remove 1 from x offset and add 1 when released.
When right is pressed, add 1 to x offset and remove 1 when released.
When down is pressed, remove 1 from y offset and add 1 when released.
When up is pressed, add 1 to y offset and remove 1 when released.

If both offsets enter the 0 state when a movement direction is pressed or released, turn off the perodic movememnt trigger.
If both offsets were in the 0 state but enter the non 0 state then turn on the perodic movement trigger.

That simple
 
Level 6
Joined
May 1, 2009
Messages
156
Urg, that was stupid of me to ask, I already knew to do the movement thing, it was turning I was curious about, but I'll ask about that when I need it. I actually got a lot out this anyway, moving unit while playing animation makes much more sense.

One more thing, not answered was the diagonal movement, can you have it so if you're already holding down the left key and then you press the up key while still holding left to flow from moving left to move diagonally top left? Or must the left key be re-pressed or something? Just anything on diagonal movement. Rep+ to all after last diagonal question.
 
You have a perodic trigger which moves him to his current location + x offset and y offset. This trigger should use game time
When left is pressed, remove 1 from x offset and add 1 when released.
When right is pressed, add 1 to x offset and remove 1 when released.
When down is pressed, remove 1 from y offset and add 1 when released.
When up is pressed, add 1 to y offset and remove 1 when released.

If both offsets enter the 0 state when a movement direction is pressed or released, turn off the perodic movememnt trigger.
If both offsets were in the 0 state but enter the non 0 state then turn on the perodic movement trigger.

That simple

/logic
 
Urg, that was stupid of me to ask, I already knew to do the movement thing, it was turning I was curious about, but I'll ask about that when I need it. I actually got a lot out this anyway, moving unit while playing animation makes much more sense.

One more thing, not answered was the diagonal movement, can you have it so if you're already holding down the left key and then you press the up key while still holding left to flow from moving left to move diagonally top left? Or must the left key be re-pressed or something? Just anything on diagonal movement. Rep+ to all after last diagonal question.

with the triggers explained above,
the unit will constantly move in the pressed direction until the button is released.

therefore, if two buttons are pressed at the same time, the unit will move in both directions at the same time, which, if those buttons are in non opposing directions, will make a diagonal.
 
Level 1
Joined
Aug 4, 2010
Messages
4
Wow that is so much better than the mess I created. What I did was this.

I created two regions called left/right and up/down.
left/right had a width of the entire map and a height of 1 grid square.
up/down had a height of the entire map and a width of 1 grid square.

Then I made 4 regions called north, east, south and west.

I made a trigger so that every 1 game second, this:

Region - Move left/right to (Center of (Selected units for player 1))
Region - Move up/dwn to (Center of (Selected units for player 1))
Region - Move North to (Top-right of up/dwn bounds)
Region - Move East to (Top-right of left/right bounds)
Region - Move South to (Bottom-left of up/dwn bounds)
Region - Move West to (Bottom-left of left/right bounds)

Then made the movement triggers as follows:

Move North:

UI - Player Any Player presses Up key Down with shift Exclude, control Exclude, alt Exclude
Trigger - Turn north (S) On
Trigger - Turn east (S) Off
Trigger - Turn south (S) Off
Trigger - Turn west (S) Off
Unit - Order (Unit 1 from (Selected units for player 1)) to ( Move targeting (Center of North)) (Replace Existing Orders)

That is to move him.... to stop him is this:

north (S)

UI - Player Any Player presses Up key Up with shift Exclude, control Exclude, alt Exclude
Unit - Order (Unit 1 from (Selected units for player 1)) to ( Stop) (Replace Existing Orders)

I did the same for east, south and west.

It all works fine with no bugs but damn thats a lot of work for something that you have explained to be a lot easier to accomplish.

Thanks.
 
Level 1
Joined
Aug 4, 2010
Messages
4
Here's my revised version...

====== START NORTH ======
Event:
UI - Player Any Player presses Up key Down with shift Exclude, control Exclude, alt Exclude

Condition:
startNorth == 1

Action:
Variable - Set alwaysNorth = 1

Animation - Play Walk Attack animation for (Actor for (Unit 1 from (Selected units for player 1))) as Default, using Play Forever, Model Driven Looping options and Default Time blend time

Unit - Make (Unit 1 from (Selected units for player 1)) face 90.0 over 0.3 seconds

===== ALWAYS MOVE NORTH =====

Event:
Timer - Every 0.0001 seconds of Game Time

Condition:
alwaysNorth == 1

Action:
Data Table - Save (Position of (Unit 1 from (Selected units for player 1))) as "point" in the Global data table

Unit - Move (Unit 1 from (Selected units for player 1)) instantly to (("point" from the Global data table) offset by (0.0, 0.3)) (Blend)


===== STOP GOING NORTH =====

Event:
UI - Player Any Player presses Up key Up with shift Exclude, control Exclude, alt Exclude

Condition:
stopNorth == 1

Action:
Variable - Set alwaysNorth = 0
Animation - Play Stand animation for (Actor for (Unit 1 from (Selected units for player 1))) as Default, using Play Forever options and Default Time blend time

=======================

Just do the same for East, South and West.... and make the units turn respectively for each. This is still very buggy but its a start. Thanks to this thread I got the idea to do this right and it works pretty good so far.
 
Status
Not open for further replies.
Top