Issue with DamageText Prefab

For some reason my DamageText Prefab is not able to be placed into DamageTextSpawner slot like in the lecture. I had to make an empty object and place the original prefab into it in order to see the text in prefab edit mode, something Sam says some people may have to do. There is no mention if there will be issues or workarounds for this in any other lectures. What do I do in this situation?

Hi Sean,

Of what type is the component you are trying to assign to the “None (Damage Text)” field? And what type does the variable have? Bear in mind that a variable of type Text accepts a Text object only, not a TextMeshPro object or an Image object or something else.

I’m going off the Video workaround Sam suggests. (place the canvas/text into an empty game object) Of course this means it’s now a game object and not a canvas. My issue is that Sam doesn’t say how to place that game object into the slot that needs a canvas prefab. I’ve seen people talk about this workaround in questions and I completely understand what the issue is, but when I attempt to alter my code to make the slot take a game object rather than a canvas, I get errors. I’m asking for a SOLID, error free way of doing this since it’s not in any lecture videos.

Hey Sean,

I’m getting confused at whos at which place and whos issue is at what, This is not your fault this is mine with discord names, community names and udemy names all being a bit different and the issues similar.

I am sure you have bumped into Jake on the Udemy Q&A who has had similar issues.

Anyways if you can provide a link to the project at this state here in this thread i can try to pick it up when i can :slight_smile:


Hey Marc, my Discord name is Dreglin (I try to keep the same image on all platforms)

Here is a link to my project:

Be sure to open the one that has a (4) at the end, since i’m sure you have 3 other copies by now. :slight_smile:
This version should be about the same as the last but without the saving errors and up to lecture #164. There is however a new error doing something with a preview window that showed up after I did lecture #164… Go figure.

This is really odd as i boot up the project and everything is all attached but the logic is reversed.
The value on the player is what is displayed when the player is hit and vice versa so you have some reversed logic there somewhere.

I am not sure why you cant drag the text in but try deleting the library files and go from there

Soooo… Did the Library delete, checked all my code against the GitHub commits, watched exactly how Sam makes the original prefab, did it the exact same way, can’t see the text, but added the prefab anyways. Tested the game once again… Damage text floats off both the enemy and the player, but neither of the values are what they should be. a 0 (zero) floats off the player though the console says 5 damage and a 3 from the enemy, though he is taking 22.6 damage.

(Marc, realized I uploaded the version without the game object prefab and had the canvas version that you can not see the text when editing the prefab.)

At the 8 minute mark in lecture 160 Sam shows the alternative workaround for people that can’t see the text in the Damage Text Prefab. This is / was what my original problem / question had to do with. AT NO POINT AFTER THIS does Sam mention this workaround or how to use it. It is a Game Object at this point, not a canvas. The slot in my first posts image requires a canvas item, not a game object.

I would like to know how to use this game object so that I can see my text first off, then I would like to know why my values are all jacked up. I can’t see anything different code wise (I’ve checked 4 times now). So what else could cause this?

Quick video :

The 3 value is what is set on the enemy.
The 0 value is also what is set on the player.

The issue seems to be that its not in the displaying of the text but of where its getting the information from as its applying the damage correctly i believe if you check against the health loss on the player and enemy as it should get from the weapon.

The values are actually correct. I took a step back and re-watched lecture 164 2 more times. (kids being noisy the first 2 times) and it seems I missed Sam saying the set values (0, 3) will be displayed. 165 covers the next part.

so now back to what I was asking originally… how do I make it so I can either see the text Sam’s way, which at this point doesn’t seem to be possible, or use the empty GameObject with the canvas as a child, where I can see the text but can’t add it to the spawner because it’s a GameObject and not a CanvasObject.

My version (notice the canvas environment… and not being able to see the text)

Sam’s version in the Lecture (no canvas environment)

Attempted to move on but once again, the text issue comes up in lecture 166. Need to know how to use the Game Object with the Canvas / Text as a child since I can’t adjust anything in the lecture or see my text inside a Canvas Environment.

This is confusing. I have made a patch to the “Using Unity Events” at 8:55 which is uploading now. Let me know if it helps.

1 Like

Here is what I have at this point after seeing the new edit Sam made:
DamageText prefab inside an empty object
Inspector for DamageTextContainer


and the Text
This seems to have done the trick for now, though I seem to be missing the text for the final blow… Maybe this gets covered later on.

Thank you.

Just to add before the topic closes, The last hit not appearing is a choice i believe thats made in the way the code is written and doesnt get changed it should be fairly easy to change though.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms