Nuc
Nuc
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
Does anyone know why after doing a Diagonal_Top "keySlots" is breaking?
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
E.g. in this case, key 1 is moved to where key 2 is, and key 6 is moved to where key 8 is.
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
Movements are based off a list of integers of where each key should move to.
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
as you can see these values are completely incorrect
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
The left is after the Diagonal_Top, and the right is after the Shuffle_Up
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
This is how this current code is attempting to shuffle the keys after the "Shuffle_Up" (the second movement)
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
public class Movement {
public string movementName { get; set; }
public List<int> keyTable { get; set; }
}

public class GameManager : MonoBehaviour {
List<Movement> movements = new List<Movement>()
{
new Movement()
{
movementName = "Shuffle_Up",
keyTable = new List<int>()
{
2,
4,
1,
6,
3,
8,
5,
7
}
},

/*new Movement()
{
movementName = "Shuffle_Down",
keyTable = new List<int>()
{
3,
1,
5,
2,
7,
4,
8,
6,
}
},*/

new Movement()
{
movementName = "Diagonal_Top",
keyTable = new List<int>()
{
8,
7,
3,
4,
5,
6,
2,
1,
}
}
};


public GameObject keySet;

public int shuffleCount;
public float shuffleTime;
public float shuffleSpeed;

List<int> keySlots = new List<int>()
{
0,
1,
2,
3,
4,
5,
6,
7
};

List<GameObject> keys = new List<GameObject>();

Color32 normalColour = new Color32(255, 255, 255, 255);
Color32 indicateColour = new Color32(0, 255, 0, 255);

void Start() {
for (int i = 0; i < keySet.transform.childCount; i++)
{
keys.Add(keySet.transform.GetChild(i).gameObject);
}

StartCoroutine(GameStart());
}

IEnumerator GameStart() {
yield return new WaitForSecondsRealtime(1f);

GameObject key = keys[Random.Range(0, keys.Count - 1)];

StartCoroutine(Lerp("colour", key, .5f, normalColour, indicateColour));

yield return new WaitForSecondsRealtime(1f);

StartCoroutine(Lerp("colour", key, .5f, indicateColour, normalColour));

yield return new WaitForSecondsRealtime(1f);

for (int i = 0; i < shuffleCount; i++)
{
Movement selectedMovement;
//Movement selectedMovement = movements[Random.Range(0, movements.Count)];
if (i % 2 == 0)
{
selectedMovement = movements[1];
}
else
{
selectedMovement = movements[0];
}

print(selectedMovement.movementName);

for (int c = 0; c < keys.Count; c++)
{
int nextPos = selectedMovement.keyTable[c] - 1;

//StartCoroutine(Lerp("movement", keys[keySlots[c]], shuffleSpeed, keys[keySlots[c]].transform.position, keys[keySlots[nextPos]].transform.position));
}

for (int c = 0; c < keySlots.Count; c++)
{
int newKey = selectedMovement.keyTable.IndexOf(keySlots[c] + 1);

keySlots[c] = newKey;

print(i + " " + (newKey + 1));
}

yield return new WaitForSecondsRealtime(shuffleTime);
}
}
public class Movement {
public string movementName { get; set; }
public List<int> keyTable { get; set; }
}

public class GameManager : MonoBehaviour {
List<Movement> movements = new List<Movement>()
{
new Movement()
{
movementName = "Shuffle_Up",
keyTable = new List<int>()
{
2,
4,
1,
6,
3,
8,
5,
7
}
},

/*new Movement()
{
movementName = "Shuffle_Down",
keyTable = new List<int>()
{
3,
1,
5,
2,
7,
4,
8,
6,
}
},*/

new Movement()
{
movementName = "Diagonal_Top",
keyTable = new List<int>()
{
8,
7,
3,
4,
5,
6,
2,
1,
}
}
};


public GameObject keySet;

public int shuffleCount;
public float shuffleTime;
public float shuffleSpeed;

List<int> keySlots = new List<int>()
{
0,
1,
2,
3,
4,
5,
6,
7
};

List<GameObject> keys = new List<GameObject>();

Color32 normalColour = new Color32(255, 255, 255, 255);
Color32 indicateColour = new Color32(0, 255, 0, 255);

void Start() {
for (int i = 0; i < keySet.transform.childCount; i++)
{
keys.Add(keySet.transform.GetChild(i).gameObject);
}

StartCoroutine(GameStart());
}

IEnumerator GameStart() {
yield return new WaitForSecondsRealtime(1f);

GameObject key = keys[Random.Range(0, keys.Count - 1)];

StartCoroutine(Lerp("colour", key, .5f, normalColour, indicateColour));

yield return new WaitForSecondsRealtime(1f);

StartCoroutine(Lerp("colour", key, .5f, indicateColour, normalColour));

yield return new WaitForSecondsRealtime(1f);

for (int i = 0; i < shuffleCount; i++)
{
Movement selectedMovement;
//Movement selectedMovement = movements[Random.Range(0, movements.Count)];
if (i % 2 == 0)
{
selectedMovement = movements[1];
}
else
{
selectedMovement = movements[0];
}

print(selectedMovement.movementName);

for (int c = 0; c < keys.Count; c++)
{
int nextPos = selectedMovement.keyTable[c] - 1;

//StartCoroutine(Lerp("movement", keys[keySlots[c]], shuffleSpeed, keys[keySlots[c]].transform.position, keys[keySlots[nextPos]].transform.position));
}

for (int c = 0; c < keySlots.Count; c++)
{
int newKey = selectedMovement.keyTable.IndexOf(keySlots[c] + 1);

keySlots[c] = newKey;

print(i + " " + (newKey + 1));
}

yield return new WaitForSecondsRealtime(shuffleTime);
}
}
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
Code shown below:
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
with the slots being completely incorrect.
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
However, if it does a "Diagonal_Top", then one of the shuffles, it will completely break the keySlots table
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
Movements "Shuffle_Up" and "Shuffle_Down" work perfectly fine.
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
The keys in the positions (1-8) are in an array called "keySlots"
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
All the keys are in the array "keys"
18 replies
CC#
Created by Nuc on 3/2/2023 in #help
❔ Key Shuffle Logic Error
Ok so I have a project where there are 8 keys that shuffle through different movements.
18 replies
CC#
Created by Nuc on 12/11/2022 in #help
❔ Mic input problem
Still no solution.
3 replies