floating text above enemy

I’m trying to create a falling word game (code here). I want the words to be assigned to 3 enemies that spawn from the top of the screen and fall down to the bottom. I have created a prefab of the eneny Here is the script that is used to spawn the enemy:

  public GameObject enemy;        
    public int count;
    public float waitTime;
    public float startTime;
    public float waveWiat;
    void Start()

    IEnumerator SpawnWaves()
        yield return new WaitForSeconds(startTime);
        while (true)
            for (int i = 0; i < count; i++)
                Instantiate(enemy, new Vector3(Random.Range(-5.0f, 5.0f), 6.3f, 0), Quaternion.identity);
                yield return new WaitForSeconds(waitTime);
            yield return new WaitForSeconds(waveWiat);

This is the word spawner script that uses a word prefab to spawn words.

public class WordSpawner : MonoBehaviour {

public GameObject wordPrefab;
public Transform wordCanvas;

public WordDisplay SpawnWord()
    GameObject wordObj = Instantiate(wordPrefab,  wordCanvas);
    WordDisplay wordDisplay = wordObj.GetComponent<WordDisplay>();
    return wordDisplay;

The words are spawning on the screen and so are the enemies. But I’m unable to get the words to be above the enemy like a floating text. How can I get this to work.

Hey there,

i’d suggest you add a Text Mesh.

Add an empty child transform to your dropping enemies. Put the text mesh component on this new transform. Scale it to ~0.01 in all axes. Set the font size accordingly high. (e.g. 200) . This is needed to make the text not be pixeled as ****. Then you simply add the text to this component that should be displayed.
The text should now be fixed to your enemy and should automatically spawn with it when you add it to your enemy prefab.

Hope this helps.
If something was not clear regarding this feel free to ask.

@singlearrowgames I once struggled with this problem. I don’t know if this is the best way to fix your problem but this is what I did… so add a Canvas to your enemy and set the render mode to world space then if you have textmeshpro (which I would recommend to anybody), add a text object to the canvas and play with the scale of the canvas and the text object until you are satisfied. I hope i was able to help.