That would work too, though there would be some redundancy when it comes to checking conditions.
It's more efficient process wise to have one move loop trigger declared for each player.
That way, if a player is not moving, their move trigger can be disabled and its less taxing on the processor.
With a single universal move trigger, it should be possible to have Periodic Events that are independent of each other.
Say I have trigger T.
I have 2 Periodic events attached to it, One for each player.
The first Periodic event would exclusively move only player 1, no conditions required.
The second would exclusively move only player 2. Though I'm not too sure what the best way to trigger this is.. Its debatable.
Trigger Array, One looping movement trigger for each player in game.
2 Integer Arrays for Vertical and Horizonal Movement.
The integer arrays should be flagged ±1 for pressed, 0 for unpressed.
If W is pressed, Vertical += 1, if S is pressed, Vert -=1. Vice versa for unpressed.
This way if both Up/Down are pressed, it will equate zero and the condition below this one will be false.Same case with Left/Right
Take the sum of the key integers
Vert[playerNum] + Horz[playerNum]
If it's NOT 0, it means there is a key pressed. [<= The Condition]
On the vertical axis, 1 would mean forward movement, -1 would mean backwards. Same case for horizontal, left or right, you decide.
As long as the sum of all the key integers is NOT 0, it means there is a key pressed and movement should occur, so enable the corresponding movement loop trigger for that player.
In the movement trigger, Simply calculate movement based off the Vertical and Horizontal States.
@crazyfingers619: Go
Theres a function to disable/enable specific triggers. You could use that to pause the movement triggers when they are not needed.
@ChromiumBoy: Go
That would work too, though there would be some redundancy when it comes to checking conditions.
It's more efficient process wise to have one move loop trigger declared for each player.
That way, if a player is not moving, their move trigger can be disabled and its less taxing on the processor.
With a single universal move trigger, it should be possible to have Periodic Events that are independent of each other.
Say I have trigger T.
I have 2 Periodic events attached to it, One for each player. The first Periodic event would exclusively move only player 1, no conditions required. The second would exclusively move only player 2. Though I'm not too sure what the best way to trigger this is.. Its debatable.
You will need:
The integer arrays should be flagged ±1 for pressed, 0 for unpressed.
If W is pressed, Vertical += 1, if S is pressed, Vert -=1. Vice versa for unpressed.
This way if both Up/Down are pressed, it will equate zero and the condition below this one will be false.Same case with Left/Right
Take the sum of the key integers
Vert[playerNum] + Horz[playerNum]
If it's NOT 0, it means there is a key pressed. [<= The Condition]
On the vertical axis, 1 would mean forward movement, -1 would mean backwards. Same case for horizontal, left or right, you decide.
As long as the sum of all the key integers is NOT 0, it means there is a key pressed and movement should occur, so enable the corresponding movement loop trigger for that player.
In the movement trigger, Simply calculate movement based off the Vertical and Horizontal States.
I hope that made sense. :)