I'm not sure how to explain this - or if I'm posting under the right topic/headline. So I posted here in Construct 2 General.
I'll try and do my best to be as concrete and simple as possible.
First my problem.
Construct wont read values from two separate arrays "at the same time".
What I have is
a 2 Player game.
Player 1 has an own dedicated Array
Player 2 also has an own dedicated Array
The Player(s) has steering and can be controlled "RotateLeft" , "RotateRight" , "Forward" , "Backward"
The Player(s) dont use the bullet behaviour to move or to rotate this is important.
So forth I have 16 cells with static values in an Array 0-15, they contain the Angle the player should rotate to. This is used to make a "Direction-Based Sprite Animation" ...Like old school games that has a separate animation-sprite that faces and "walks" in the direction the player is moving.
I'm using the array to store the angle the player should rotate to - in 22.5degrees increment . Like 0 degrees, 22.5 degrees, 45, 67.5, 90 degrees and so on.
When "RightArrow" are held down - a Function are Called that read a value from the Players dedicated Array. And use that value to set the players angle. ( I explain more further down)
The Player object and the Array object are in a container
The thing is.
...And the function works like this:
I'm holding down "RightArrow"
The Keyboard event calls a function: Function Call "SteerRight" ("Player1") I'm sending Player1 along as a parameter.
In the function "SteerRight" the first event are a Pick by Comparison, and the player object gets picked that has "Player1" in an Identification variable.
Then immediately I set the players angle by reading a instance variable from the player... Player.State and using that to choose which cell from the players Array that should be read. Like this... Set Angle to ArrayPlayer.At(ArrayPlayer.State)
After that I have an Event that adds 1 to another variable called KeyDown
When KeyDown are Greater than 10 ...I add 1 to the Player.State variable.
Then if Player.State are Greater or Equal to 16 it reset the Player.State to 0. So the state starts back at state zero. A full 360degree circle.
Thats the function... that gets called constantly as long as I hold down the right arrow-key.
This works perfectly with ONLY one player.
The player rotate both clockwise and cclockwise, I can move forward (thats another function with no array) and move backward.
ALSO when I use the Player2 controls ( WASD) it also works perfectly.
I have checked the Arrays in the Debug layout and everything looks fine. The Player1 Array are read independently from the Player2 array. I've checked the variables and every instance of the objects and so on. It all looks fine.
Now here's my problem
If I hold the right arrow-key down (rotateClockwise) AND the D-key (rotateClockwise for Player2) down simultaneously - the Player1 and Player2 should both rotate clockwise. But they are not.
Only one of the players do. And the other players Array does not get read at all.
It's like one array gets priority over the other or something?
This is a big problem, cause you kind of wanna be able to steer both the players at the same time - otherwise its not a 2 player game
The big strange thing is that if I use traditional ways to rotate the players IT WORKS???
I tried this because i first thought you could not call the same function at the same time like this. But YOU CAN.
If I instead have the function "SteerRight"
And inside I simply have Rotate 2 degrees clockwise. ...Yes I send along the "Player1" or "Player2" parameter and have a Pick by Comparison event first, so either the Player1 or Player2 gets picked.
Everything works fine. The Player1 and Player2 both can be steered independently and at the same time with no problems.
I can have as many players as I want this way.
But if I have the array in the function and I have to read something from one of the arrays cells, it does not work?
Probably I could achieve the same result I'm after in a different way, without arrays. But I just wanted to know why I cant use a Function Call like this when there is an Array involved?
Does anyone know what is happening here in the Construct 2 mechanics or have good ideas of what's wrong?
I apologize for my wearisomely explanations - I hope someone understands them.
And thanks for reading this far *HUG*
If anyone wants to, I can upload a .CAPX in the future.