How to randomly create 2D emoticons (assets) based on array.,
Hi, I'm a complete newbie to Unity and programming. I'm making a pet simulator and I want to create emoticons based on the pet's state. I want a list where emoticons can be added or removed depending on the pet's state. Then when user clicks on the pet, it'll randomly create an emoticon from the list. The emoticon will appear above the pet and follow the pet for a while before fading and removing itself.
And I've seen a tutorial where i need to create an Empty gameobject as a prefab. I'm able to call out and destroy the Prefab, but its an empty prefab, and it doesn't follow the Pet (even though its supposed to).
public class KillSelfScript : MonoBehaviour { public Transform objectToFollow; //public Vector3 offset;
public float lifetime;
// Start is called before the first frame update
void Start()
{
Destroy(gameObject, lifetime);
}
// Update is called once per frame
void Update()
{
transform.position = objectToFollow.position;
}
}
The issue now is that my Empty GameObject has nothing to it. If I have multiple emoticons, how do I change that prefab to my emoticon or make the prefab display the emoticon from the lists of emoticons? Or is there a better way to achieve what I want?
Your answer
Follow this Question
Related Questions
reference instantiated prefab on a scroll list? 0 Answers
How to get tooltips to pop up on certain levels, but not all of them 2 Answers
List Null Ref 1 Answer
Problem with List.Addrange 1 Answer