Hello, I have a problem with my function that reads instructions within my list. I need to create a condition that when dragging the block it assumes that instruction in this case the directions work well but when I drag more than one block that changes the character’s sprite it always assumes the last one for example if: → + → + rotateLeft + v + rotateRight The symbols represent the arrows that move the character forward and the rotateLeft and rotateRight is when changing sprites. how can i solve this problem?
this is my function:
public void movimentsOfPlayer(){
for (int i = 0; i < player.itemsList.Count; i++) {
if (player.itemsList .name.Contains ("rotateUp")) {
spritePlayerRenderer.sprite = ImagePlayerRotateArray [0];
}
if (player.itemsList .name.Contains ("rotateDown")) {
spritePlayerRenderer.sprite = ImagePlayerRotateArray [1];
}
if (player.itemsList .name.Contains ("rotateLeft")) {
spritePlayerRenderer.sprite = ImagePlayerRotateArray [3];
}
if (player.itemsList .name.Contains ("rotateRight")) {
spritePlayerRenderer.sprite = ImagePlayerRotateArray [2];
}
if (player.itemsList .name.Contains ("handleCatch")) {
}
if (player.itemsList .name.Contains ("moveUp")) {
movimentsList.Add (Vector3.up);
}
else if (player.itemsList .name.Contains ("moveDown") ) {
movimentsList.Add (Vector3.down);
} else if (player.itemsList .name.Contains ("moveLeft") ) {
movimentsList.Add (Vector3.left);
} else if (player.itemsList .name.Contains ("moveRight") ) {
movimentsList.Add (Vector3.right);
}
}
}