I am trying to make a slot machine in Unity right now, and i have come to a stop. I have figured out how to randomize the sprites, but i cant seem to figure out, how to make you “win” like make a script that checks if three identical sprites are next to each other, is there a way to do that or is it impossible.
Mind you i am VERY new to coding, so if you would like to help me please explain why or why it isn’t possible;)
I would make it so that the game didn’t actually check the sprite, but the “state” of each “slot”. The sprite would just be for show, but the real logic would assess the state of each slot, be it a numerical value comparison, or some other comparison.
That would probably be a bit easier, depending on your setup.
How do you select which sprite to display now? If you can choose a sprite, then you should be able to identify it as well by the same logic.
1 Like
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Symbol_Spawner : MonoBehaviour
{
private int rand;
public Sprite[] Sprite_Pic;
// Start is called before the first frame update
void Start()
{
Change();
}
// Update is called once per frame
void Update()
{
if (transform.position.z == (-16))
{
Change();
}
}
void Change()
{
rand = Random.Range(0, Sprite_Pic.Length);
GetComponent<SpriteRenderer>().sprite = Sprite_Pic[rand];
}
}
And then i set the 8 different sprites
So giving my gameobjects a value, and then making a script checking what value it is?