Hi, thank you but this is for a 2D game. Right now I’m trying to figure out how to instantiate something and then change it’s value. I thought about putting it in the prefab but I’m not sure if it will work
One thing you could do is to instantiate a UI text object and reference that to change the number it reads. That way you don't need to have a bunch of sprites for every number and you have control over color and the font!
Comments
Greetings,
You should try something from this code here: https://github.com/AustinsOffice/Floating-Damage-Text-in-Unity/tree/master/Assets
Keep on Creating!
Justin of JustinTime Studios (http://unity3d.expert)
Hi, thank you but this is for a 2D game. Right now I’m trying to figure out how to instantiate something and then change it’s value. I thought about putting it in the prefab but I’m not sure if it will work
Do you mean pop up like having a particle system for it? If so, I believe you'd want to search for how to change the texture of the particle system dynamically? A quick Google found this - https://answers.unity.com/questions/1492436/how-to-change-particle-texture-of-a-particle-syste.html
Not sure if this is what you want.
I'm still inexperienced so I may be 100% wrong in all of this.
One thing you could do is to instantiate a UI text object and reference that to change the number it reads. That way you don't need to have a bunch of sprites for every number and you have control over color and the font!
How would I change the text then?
Well changing text is actually quite simple. Here is an example in the Unity Documentation: https://docs.unity3d.com/2017.3/Documentation/ScriptReference/UI.Text-text.html.
And after a quick google search I found this video: https://www.youtube.com/watch?v=iD1_JczQcFY. That'll explain a pretty easy system for creating damage popups like this.
Nevermins I think I got this