gewoon_kiefer
gewoon_kiefer
NNormal
Created by gewoon_kiefer on 3/6/2025 in #🤝ask-a-question
how to sync scriptable objects
@kapa.ai how to use the RandomSeedSync script and make a new random seed
23 replies
NNormal
Created by gewoon_kiefer on 3/6/2025 in #🤝ask-a-question
how to sync scriptable objects
oke thx
23 replies
NNormal
Created by gewoon_kiefer on 3/6/2025 in #🤝ask-a-question
how to sync scriptable objects
how do i create a random seed that the server has then?
23 replies
NNormal
Created by gewoon_kiefer on 3/6/2025 in #🤝ask-a-question
how to sync scriptable objects
c#
// for the amount of ColorAmount create a new color and spawn the color in the world
for (int i = 0; i < ColorAmount; i++)
{
SimonColorSo color = null;

// change the way i create a random simonColorSo based on if the bool everyColorOnce is true or false
if (everyColorOnce)
{
color = CreateRandomColor(gottenColors);

gottenColors.Add(color);

if (gottenColors.Count == simonColors.Count)
{
gottenColors.Clear();
}
}
else
{
color = CreateRandomColor();
}

simonColorOrder.simonOrder.Add(color);

GameObject visualColor = Realtime.Instantiate(displayName, displayLocation.transform.position, Quaternion.identity);
visualColor.transform.parent = displayLocation.transform;
visualColor.GetComponent<SimonColorDisplay>().SetInfo(color);

visualColors.Add(visualColor);
}
}

// randomizes the color i get
SimonColorSo CreateRandomColor()
{
int maxOption = simonColors.Count * amountChancePerColor;
int result = Random.Range(1, maxOption);

return simonColors[Mathf.FloorToInt(result / amountChancePerColor)];
}

// checks if i the color i got is in the list
SimonColorSo CreateRandomColor(List<SimonColorSo> checkList)
{
SimonColorSo color = CreateRandomColor();

if(!checkList.Contains(color))
{
return color;
}
else
{
return CreateRandomColor(checkList);
}
}

void ResetVisualColors()
{
if(visualColors.Count != 0)
{
foreach (var obj in visualColors)
{
Destroy(obj);
}
visualColors.Clear();
}
}

}
c#
// for the amount of ColorAmount create a new color and spawn the color in the world
for (int i = 0; i < ColorAmount; i++)
{
SimonColorSo color = null;

// change the way i create a random simonColorSo based on if the bool everyColorOnce is true or false
if (everyColorOnce)
{
color = CreateRandomColor(gottenColors);

gottenColors.Add(color);

if (gottenColors.Count == simonColors.Count)
{
gottenColors.Clear();
}
}
else
{
color = CreateRandomColor();
}

simonColorOrder.simonOrder.Add(color);

GameObject visualColor = Realtime.Instantiate(displayName, displayLocation.transform.position, Quaternion.identity);
visualColor.transform.parent = displayLocation.transform;
visualColor.GetComponent<SimonColorDisplay>().SetInfo(color);

visualColors.Add(visualColor);
}
}

// randomizes the color i get
SimonColorSo CreateRandomColor()
{
int maxOption = simonColors.Count * amountChancePerColor;
int result = Random.Range(1, maxOption);

return simonColors[Mathf.FloorToInt(result / amountChancePerColor)];
}

// checks if i the color i got is in the list
SimonColorSo CreateRandomColor(List<SimonColorSo> checkList)
{
SimonColorSo color = CreateRandomColor();

if(!checkList.Contains(color))
{
return color;
}
else
{
return CreateRandomColor(checkList);
}
}

void ResetVisualColors()
{
if(visualColors.Count != 0)
{
foreach (var obj in visualColors)
{
Destroy(obj);
}
visualColors.Clear();
}
}

}
23 replies
NNormal
Created by gewoon_kiefer on 3/6/2025 in #🤝ask-a-question
how to sync scriptable objects
this is the script i use to randomize the order:
C#
public class SimonController : MonoBehaviour
{
#region Variables

[SerializeField] private List<SimonColorSo> simonColors = new List<SimonColorSo>();

[SerializeField] private GameObject displayLocation;
//[SerializeField] private GameObject displayPrefab;
public string displayName;
[SerializeField] private SimonColorOrderSO simonColorOrder;

[Range(4, 98)][SerializeField] private int ColorAmount;
[SerializeField] private int amountChancePerColor = 100;

private List<GameObject> visualColors = new List<GameObject>();
[SerializeField] private bool everyColorOnce = false;

bool spawnOnce = true;
#endregion

private void Update()
{
if (spawnOnce)
{
NewColorSet();
spawnOnce = false;
}
}

// make a new set of colors based on the variables maxRandomColorSize and minRandomColorSize
public void NewColorSet()
{
ResetVisualColors();

simonColorOrder.simonOrder.Clear();

List<SimonColorSo> gottenColors = new List<SimonColorSo>();
C#
public class SimonController : MonoBehaviour
{
#region Variables

[SerializeField] private List<SimonColorSo> simonColors = new List<SimonColorSo>();

[SerializeField] private GameObject displayLocation;
//[SerializeField] private GameObject displayPrefab;
public string displayName;
[SerializeField] private SimonColorOrderSO simonColorOrder;

[Range(4, 98)][SerializeField] private int ColorAmount;
[SerializeField] private int amountChancePerColor = 100;

private List<GameObject> visualColors = new List<GameObject>();
[SerializeField] private bool everyColorOnce = false;

bool spawnOnce = true;
#endregion

private void Update()
{
if (spawnOnce)
{
NewColorSet();
spawnOnce = false;
}
}

// make a new set of colors based on the variables maxRandomColorSize and minRandomColorSize
public void NewColorSet()
{
ResetVisualColors();

simonColorOrder.simonOrder.Clear();

List<SimonColorSo> gottenColors = new List<SimonColorSo>();
23 replies