Maybe this is to advanced for now but I was curious how to have a different pic come up for each state?
It depends on how you’ve written your script. I’d suggest playing around with swapping images around via an array and working out how this works and then building it in to your game.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ImageSwapper : MonoBehaviour {
public Sprite[] imageArray;
private Image image;
private int imageCount = 0;
void Start () {
image = GetComponent<Image>();
}
void Update () {
if (Input.GetKeyDown(KeyCode.Q)) {
image.sprite = imageArray[imageCount];
imageCount++;
if (imageCount > imageArray.Length-1) imageCount = 0;
}
}
}
I’ve set this up to be attached to the image itself. It has 3 variables; image is the image itself and how we’ll talk about it, imageArray is an array of sprites which we’ll attach to the script and imageCount which is just an easy way to keep track of which part of the array is currently active.
If you put this code on your image and build it then go back into the code in the inspector you should see an entry for imageArray which will first ask for a number. This is the total number of different sprites you want to attach so if you want 3 then just type 3 in. This will then create 3 elements for you to attach sprites to it simply drag and drop from the project(remember images must be set to be sprites to work).
Now if you press Q it will cycle through your attached images. For your states you just need to assign an entry for each and call it to load each time you go into the state. The important part to remember is that arrays index from 0 so if you put 3 in earlier these are elements 0, 1 and 2 which is why the 2nd if statement has a minus 1.
I’ll have to play with this and check it out, thank you!