Hello, its not the place to ask a question, but i really wanna know another alternative. In a game im making, sometimes there are so much point popups, it affects the performance significantly. Is using text mesh pro more performance option, or is there someway i can use sprite renderers to circumvent unity's ui system?
Hi! Found your channel last week and I've been watching your videos whenever I have time. Don't know if have anything on that, but I would really like to see something turn-based, like RPGs, tactical games and card games.
If you have so many popups that is causing issues what I would do would be make a mesh based system. Game Objects are very computationally expensive so if instead of creating thousands of objects you simply have one with a mesh it will be much more performant. However that does require you to build a mesh system and handle building the quads to display each number, etc. Takes a lot of work but if you're sure that's the bottleneck then look into it. Yeah I would like to do a Turn Based tutorial, I created a simple Turn Engine for the Livestream game and I'm looking into how I can make a video about it.
If you get the following error: ArgumentExeption: "The thing that you want to instantiate is null." Make sure you've put the GameAssetrs prefab inside the Resources folder in your project hierarchy. This had me racking my brains for about an hour :)
I know it's been a while since this video was published but I used it yesterday to add really sexy damage popups to my game. Thanks so much for the tutorial!
Thank you so much for this tutorial, it really helped a lot and i learned a lot. since this is a 4 year old video there are a few issues that came up for me, ill list it here for anyone else in the future: * GameAssets requires the GameAsset to be created in the Resource folder * i had some issues with the Utils class because i'm using the new input system so i wrote my own camera to world pos for the clicking portion. * Utils class also gave me problems with the hex color conversion. so i replaced that portion of the code with new Color(R,G,B) and since im working with 16x16 grid i had to downscale the font size and some of the small float tweaks to fit my scene better. overall it worked out great and im really grateful.
to me he is at another level in programming, since i am myself a beginner(new to c# programming), its really hard to catch up. But i do learn from him how to make my program more cleaner and thank you. this video really help me a lot.
If you get runtime errors, use the type TextMeshProUGUI instead of TextMeshPro. I've had errors for DAYS and the thing didn't work until I had the bright idea to use TextMeshProUGUI. Now it works perfectly.
That depends on what object you used when making the prefab. The UGUI version is the UI version whereas the normal one is a world space text object. Both of them work the same but you do need to use the same type in code and in the editor.
Hey thanks for the video, got yourself another subscriber :) I was looking for a way to get cool looking damage numbers in a JRPG combat system, and this works great with a bit of tweeking to encorporate different colours for diferent damage elements and the like. I'm very happy with the results.
@@CodeMonkeyUnity haha nooo, why would you do this to me? I'm trying to stay focused on my development goals, I can't fall down a tangent... but it does look like it could be useful... I should probably watch it....
Thank you for this tutorial, it was very usefull! But when I tried to Refference the pfDamagePopUp with the GameAssets Skript I got the ArgumentExeption: "The thing that you want to instantiate is null." So I needed to get the refference with a workarround. Any Idea why this happened? Because I really like the Idea of the GameAssets Skript to easily acces different refferences
The reference is in the GameAssets script which is attached to a object in the scene, drag the reference on there. That object is a prefab so make sure you update the prefab after you drag the reference.
This really confused me too. @SoulsElite kindly pointed out we're missing the Resources folder, but research into Resources points out that it shouldn't be used at all: "3.1. Best Practices for the Resources System : Don't use it." :( From: learn.unity.com/tutorial/assets-resources-and-assetbundles#5c7f8528edbc2a002053b5a7
Thanks for all the great content! I for one appreciate the reasonably fast pace your videos takes - this allows you to quickly go through and understand what gets done, then pause where you need to as you dig deeper. I am a Unity Newbie, although I've been coding (older languages, mostly not object oriented unfortunately) for many years. I am trying to adjust this demo to allow me to create temporary moving icons (images) on the UI - like a gold coin jumping smoothly from one place on the UI to another and then disappearing. I used RectTransform in place of Transform. The image gets created successfully within the UI structure by specifying the parent on the Instantiate call, and simple linear movement from point A to point B within X seconds is working already. I'm now trying to get some interesting "paths" built in, still need to see how I will parameterize the Image to be shown, and I'm struggling to implement the "Destroy()" call without hard-coding the name of the object. any pointers on the Destroy call would be appreciated.
In order to Destroy all you need is a reference to the object so it depends on how you are creating and animating your icons. If you're doing a similar pattern in the video where the icon moves itself you can do the same thing Destroy(gameObject); If you're spawning them in sort sort of UI Script then that script needs a list of the currently active popups and call Destroy on them when it's time. For some interesting paths you can either do like I did in the video and make it code based or you can also create a AnimationClip.
Well done CM. From a coder perspective nice, but I guess these things mostly are done with animation (moving, disappearing parts). Overall, thanks again for the great work.
If want to do 3D, some of the systems between 2D and 3D are similar. I started learning 3D and a lot of the systems are similar with minor changes to the syntax as it is (x,y) vs. (x,y,z)
If someone having Text not showing or disappearing after damage popup is spawned, this might help - “If you are using a mixture of normal TextMeshPro objects and TextMeshProUGUI objects which happen to share the same material preset, this can produce this behavior as the MeshRenderer and CanvasRenderer systems are fighting over the ZTest on these objects. Solution: If that is the case, the solution is to have a set of Material Presets for the normal text objects which are in worldspace and another set for the objects using the canvas system”
Very good turorial! I, however, think that the sortingOrder solution should be re-thinked. You will eventually (even though it might take a while) run into an integer overflow exception
Not a big deal. At some point a single group would be have wrong sorting order but it would fix itself. However if you are concerned you can set it to 0 when there is no shown damage
In my case when I was following the tutorial step by step, I had to set 'disappearTimer' variable this way: private static float disappearTimer; instead of 'non static'. Without being 'static', that variable was set to 1f in the first frame, and then suddenly to 0 in the second frame, then to 1f in the next one, and so on.
Dont worry about having to pause. Your goal should be to learn so don't worry if it takes you a while to follow the video, just make sure you understand it.
@@CodeMonkeyUnity Well, I got your point about implementation this (thanks for good explanation!) however I was curious what TextMesh settings you use to get such text design.. and it was not easy because of the speed :(
Everything seems to work fine EXCEPT getting the score to be where the mouse position is. I am in 3D and it doesnt seem to track its position. I have used the util.class and im not getting anything. Any ideas why this could be?
I keep getting a null error due to the Game Assets, I have tried make sure everything is like how yours is but I still get the nullpointer exception, help please!
MagicTimm I figured it out, you need to create a Resources Folder and then have the GameAssets Game Object within there, he was trying to call the folder Resources to load the GameAsset object.
I haven't used TMPro, and based on your video it seems it is possible to use it without a canvas, just have the RectTransform in world space? Pretty neat, and probably more performant than having zillion World Space Canvases... but how about not having Canvas scaler? How would the text be scaling in this case? I understand this is demo, but do you use this approach in your own games? Thank you for the video like always!
Yeah I'm still new to using TMPro so not too sure how they're using a RectTransform without a Canvas, I think the RectTransform is simply translating the Width, Height and Pivots into normal Transform coordinates. I haven't used TMPro in any of my published games since it has a bunch of issues when dealing with Asian languages, you need to create a atlas for each language and I haven't gotten around to figuring out how to sort that so Battle Royale Tycoon is using a normal TextMesh. The text seems to be scaling solely based on the Main Camera so it works just fine like a normal TextMesh.
Hi nice Tutorial as always. Is there a Tutorial where u build the blood effect? I know there is one for the blood trail, but there u use the finished effect. Im asking more for the blood particle effect itself?
Haven't managed to do a video on that yet, it's on my list. Essentially there's a giant mesh and every blood particle is a quad in that mesh that moves and then stops.
Hi. I have an issue with the opacity fading. The floating text moves up fine, however, it goes to transparent instantly and doesn't fade slowly. I have copied your code step for step. Any ideas?
I dont have sorting layer under extra settings.. When it shows up its behind everything. Mine says geometry sorting but it doesnt show my sorting layers to choose from, any idea why? Thanks for the videos!
No doubt one of the BEST unity teachers. Love it. Code monkey is the # 1 place to to.. I have a question. I followed the tutorial and even downloaded the project files to ensure I got every line correct. I do not have a enemy handler so I tried to use it with my own enemy script. Can you please show or explain how to set this up with an very simple enemy script?? I take damage when my bullets hit me, so I tried to put the code in there, I get error messages for the damage amount?? Please advice
Sorry about asking questions on an old vid. im just curious as to why you would make the text pop up a serialized private transform and not a public game object? is there a reason im not seeing?
If your variable is meant to be used only in a single class and not accessed from anywhere else then it should be private. In order to keep your code clean but also allow dragging references in the Editor you can make it serializable. public is essentially saying "this variable can be modified by any class anywhere" whereas private means "this variable is used in this class and this class alone, no need to worry about other classes modifying it"
I wanted to do something like when the enemy is damaged it will show the damage popup as usual however if the enemy get's the same amount of damage in rapid succession then it will reset the disappearTimer and print the damage followed by x and the amount. For example: if enemy gets hit 30 times very fast for 2.5 damage it will print 2.5 x30. Really want to know how to do this, can you make an updated tutorial if you are feeling up for it?
Not sure why, but when I finished up the 'Create' function, and I tried to do the damage testing, the pop-up failed to show up. I followed your instructions, but it just doesn't pop up.
Does anything show up? Make sure you're not instantiating a null object. Pause the scene and look at the hierarchy, maybe you're spawning objects with a weird Z position.
@@CodeMonkeyUnity Nothing shows up at all. I also reset it to 0,0,0 and it doesn't pop up. Everything else before creating the 'Create' function worked the same as yours did.
Iam really struggling with the "GameAssets" class. I made it exactly how you did in this video but i just get an error "An object reference is required for the non-static field, method or property "DamagePopup.Create(Vector3, int)"
In terms of using the "pf" prefix, nowadays I normally just add "prefab" to the end of the variable name. I started doing that because when people other than me are following a tutorial they might be confused as to what "pf" stands for so to avoid any confusion in the videos I just decided to switch that.
Hello, I am getting an error in update function, especially in this line : textMesh.color = textColor; you are implementing this at 10:50, the script is working and everything is all right, however I am getting 60 error messages per second in console saying : NullReferenceException: Object reference not set to an instance of an object. Could you help me fix this please ?
Sounds like you have your textMesh set to null, add some Debug.Log(); to find where it should have been set. Also in your console click the button that says Error Pause so your game pauses when you get an error
Would you ever redo this tutorial in 3D space? This one doesn't translate well due to the fact that gameobjects are of different sizes so at further ranges you just can't read them
I'm kinda stuck. I have the exact same scripts and I keep getting: CS0246: The type or namespace name 'TextMeshPro' could not be found (are you missing a using directive or an assembly reference?)
The text is just not visible in my project, any idea what could it be? I have it set as the highest layer and it's visible in the Scene view, but not in the game view.
Why do you use Transform for pfDamagePopUp instead of GameObject? We instantiate game objects and transform is just one of its components. Why does it work?
GameObjects and Transforms are pretty interchangeable because very Game Object has to have a Transform and every Transform has to be attached to a Game Object. So since you cannot have one without the other, instantiating a Transform or a Game Object does the same thing, the difference is just the return type on Instantiate();
Hi, how to use this code if i use Canvas? Because if i trying use ur code its spawm, but spawn not inside canvas, so in that case i cant see any text, how to fix that?
Use TextMeshPro and not TextMeshProUGUI. The first one is a world component, not a canvas component. If you absolutely need a Canvas then you can always use a World space Canvas and spawn that along with the popup ua-cam.com/video/Zwgj3mwOVlg/v-deo.html
It's all about experience, I've been writing code for 20 years and with Unity for 6 years so when I think up a system I already know what elements I'm going to need to make it work. In this case I knew I could instantiate a prefab on top of the Enemy, change the colors of the TextMeshPro component and modify it's position and scale, then it's just the matter of implementing it. The only trick is to keep writing code and making things, the more you write the easier it gets.
Pretty Nice! I've done a popup too in a 3d enviroment. My solution to have it over everything else was to have it's canvas in world space and 2 cams. One for the pop ups and the other for the game itself. Thing is the new URP dosent support camera stacking anymore. Any clean workaround? Had some folks telling to write a post process for this but feels like a overkill. Thanks in advance.
@@CodeMonkeyUnity oh you're right! Sadly I still can't have alpha to work on my popup camera anymore and it makes everything blue besides the numbers. Will check out RenderTextures. Thanks alot!
It was actually a bug in the version i was using that the Alpha in the Solid color background in the camera settings wasnt working. Updated it and it's working fine now. Thanks again for the response !
no matter how I follow your example I always get 'The Object you want to instantiate is null.' always around gameasset class. do you have any idea why? I followed the example directly.
I have this error: ArgumentException: The Object you want to instantiate is null. When I try to Instanciate the textMeshPro object. Any idea? very thanks!
Make sure the prefab you are trying to instantiate is correctly referenced. Are you trying to instantiate something from a Serialized Field? If so make sure there's a reference in the script field in the editor.
There are lots of tutorials to make like for 2d top down shooter rpg like game Shooting, enemy ai,damagable blocks, gun reload system, gun swap system etc. There are lots of tutorials to make Can you make any one of them plz?
I've been having real problems with the singleton GameAssets Class, Resources.Load... would always return null, no matter what I tried came up with this workaround get { var result = Resources.LoadAll(""); if (_i == null){ _i = new GameAssets(); _i.pfDamagePopup = Instantiate(result[0].transform); } return _i; } any idea why I couldn't get the original "automatic" solution working?
Did anyone have a problem with this rendering on the Scene tab, but not on the Game/Simulator tab? I'm doing a 2D non-scroller for mobile. Canvas is 1920 x 1080 and my Main Camera is positioned at the bottom left-hand corner 0,0 as recommended by some other tutorials. Instead of emitting the damage from enemies, I have a button that I'd like have emit the text popups when clicked. The pop-ups show in the Scene tab, but not in the game tab. I had the prefab done in 20-30 mins and I've then spent 6+ hours trying to figure out what I've done wrong. Thoughts? Long time developer and android dev for a few years, but I'm new to Unity.
It shows up in Scene view but not game view? Perhaps it is spawning behind the camera? Check the Z position Or perhaps it's spawning on a certain Layer that is not being rendered by the main camera
@@CodeMonkeyUnity Thanks for the reply! I found out that, as I was instantiating the prefab, I needed to assign it to a parent that was already on the canvas. Great video. You have me as a subscriber now.
thanks a lot for the nice video but sometimes you move mouse way too fast, that makes me rewind and slow down the speed just to see what you are doing. A good example is when you create a new sorting layer , in 07:14 - 07:19
I can see TMPro in the Scene, but not in my Game view. I checked the layers, Z axis, position, viewed it in 3d to confirm it is in the front, not hidden behind any object. I don't use any other TMPro UI object, I don't have Canvas, so nothing should interfere here. Yet it does not show in the Game view. Any ideas?
Did you check the Sorting Order and Sorting Layer? I'm assuming your scene is in 2D so those are the fields that matter, not the Z position. The background might have a higher Sorting Order and being rendered above the popup. Other than that, just make sure the Z is in front of the camera so its not being rendered behind it. Usually Z = 0
@@CodeMonkeyUnity I figured it out finally. I was confused because none of the components had sorting layer, but default sorting layer was in fact being used by renderer. The text appeared once I changed sorting layer in my script. This should be in the inspector! Thank you
When you import them you get a new Folder in your Project Files. You can then use the full name like CodeMoney.Utils.FunctionTimer.Create(); Or add using CodeMonkey.Utils; at the top then just FunctionTimer.Create(); The utilities include all the source code so check that out.
After downloading project files + utilities, new project in 2018.3.11f1 version, packages imported, press Play, and I just see huge sprites, and basically nothing work as expected. Some errors are shown: The referenced script on this Behaviour (Game Object 'Btn') is missing! The referenced script on this Behaviour (Game Object 'Clickthrough') is missing! The same happens with other tutorials, am I missing any step? Thank you.
I just imported the package into a completely empty project and everything worked fine. There are some warnings since apparently I still had some UI objects from a previous tutorial but the scene still works. What exactly do you see? Do you get any errors in the console or just the warnings? Does anything move in the screen?
@@CodeMonkeyUnity @Code Monkey Hi, check this video: ua-cam.com/video/gqQSh7bvk-0/v-deo.html Here you will see what I see when I create a new 2D project (release 2018.3.11f) and the package is imported, scene "Gamescene_Damagepopup" is loaded, and button 'Play' is pressed. Hope it helps. Sorry for the resolution. If you need further details, just let me know.
Hmmm what country are you from? I think I know what the issue might be. I've just updated the package on the website, please download it again and try it out.
@@CodeMonkeyUnity I'm from Spain (I'm a computer scientist by the way) and I hope this fact has nothing to do with these errors :-) Now it's working fine. Still a minor issue: in the 'Background' gameobject, Sprite -> Missing (sprite), so no background is displayed, only black solid color from main camera. Thank you for the corrections!
The background texture isn't included since I didn't make it, its a free texture from the Asset Store and I don't have a license to be able to distribute it.So the animations are working fine now? If so then the issue is related to how different countries use different symbols for floating points. Some countries use a Dot . and some use a Comma , It's a simple fix and something that is fixed in my own games but for these packages I forgot to add the fix directly to the animation system. Thanks for letting me know!
Wasn't familiar with JuiceFX but upon seeing the videos it seems like a really cool program. Those types of animations are certainly great for adding juice to your game. I'll look into it, thanks!
You are calling Instantiate(); and passing in null as a parameter. Check where you're getting that parameter from, use Debug.Log to find what is null ua-cam.com/video/5irv30-bTJw/v-deo.html
Canvas is only needed for UI objects, if you use World Text, you don't need a canvas, if you want to use UI Text you do need a Canvas ua-cam.com/video/Zwgj3mwOVlg/v-deo.html
I was really excited to find your channel but this is really hard to follow. I first needed to find how to import the packages, then I needed to figure out finding the same scene you used and then when I finally wanted to see what you're doing you're lightning fast. I can't even see what you're doing with the Unity Interface, this needs to be watched at 0.5x speed.
Do you mean when setting up the text object? I sped it up because the specific settings of the text object aren't really relevant to creating the popups. Your game probably has a different style than what is shown in the video so the look of the popups will be dependent on what you're using it for.
What grey boxes? Sounds like either your font size is too big or you just have no font assigned so you're just seeing empty quads. This element, like any element, can be scaled up or down
This was a really cool effect to make!
What other things would you add to it?
Hello, its not the place to ask a question, but i really wanna know another alternative. In a game im making, sometimes there are so much point popups, it affects the performance significantly. Is using text mesh pro more performance option, or is there someway i can use sprite renderers to circumvent unity's ui system?
Hi! Found your channel last week and I've been watching your videos whenever I have time. Don't know if have anything on that, but I would really like to see something turn-based, like RPGs, tactical games and card games.
@@CasualCosta Turn base system would rock, add my vote too.
If you have so many popups that is causing issues what I would do would be make a mesh based system.
Game Objects are very computationally expensive so if instead of creating thousands of objects you simply have one with a mesh it will be much more performant.
However that does require you to build a mesh system and handle building the quads to display each number, etc.
Takes a lot of work but if you're sure that's the bottleneck then look into it.
Yeah I would like to do a Turn Based tutorial, I created a simple Turn Engine for the Livestream game and I'm looking into how I can make a video about it.
I want to deal attacks to multiple enemy(1 shot 4 hit ,like that)
If you get the following error:
ArgumentExeption: "The thing that you want to instantiate is null."
Make sure you've put the GameAssetrs prefab inside the Resources folder in your project hierarchy.
This had me racking my brains for about an hour :)
u're my savior mate
Thanks!
@@4SheR Yeah it had my mind in bits for hours :D
Legend. Thanks man.
After hours of headaches, I was about to give up on this video. Really thank you very very much.
This was amazing! That's a lot!!
Highly underrated channel. It's one of the best gameDev channels I've found.
Thanks!
It's not very popular because he codes at mach 10 speed and no one can understand his complicated scripts.
@@beri4138 ok boomer
@@Zac_Bacs ok zoomer
why you lying???
I know it's been a while since this video was published but I used it yesterday to add really sexy damage popups to my game. Thanks so much for the tutorial!
I'm glad the video helped you! Best of luck with your game!
It’s crazy how often you have the exact videos that I’m looking for. So prolific.
Thank you so much for this tutorial, it really helped a lot and i learned a lot. since this is a 4 year old video there are a few issues that came up for me, ill list it here for anyone else in the future:
* GameAssets requires the GameAsset to be created in the Resource folder
* i had some issues with the Utils class because i'm using the new input system so i wrote my own camera to world pos for the clicking portion.
* Utils class also gave me problems with the hex color conversion. so i replaced that portion of the code with new Color(R,G,B)
and since im working with 16x16 grid i had to downscale the font size and some of the small float tweaks to fit my scene better. overall it worked out great and im really grateful.
jesus?
This was exactly what i was looking for, thank you.
Your ad brought me here. This was the First usefull commercial ive ever saw
Glad you like what you see!
to me he is at another level in programming, since i am myself a beginner(new to c# programming), its really hard to catch up. But i do learn from him how to make my program more cleaner and thank you. this video really help me a lot.
It's all about experience, I've been writing code for 20 years so just keep at it and you'll get there one day!
Is that intro new? Its the first time i noticed it, it looks really nice.
Yeah trying out a couple of new things, glad you like it!
Instantly subscribed after this , and added to my RPG Game!!!
You're the best. Really, I did not believe I could implement that so easily !
this really helped me with my game mane, thanks a lot for the tutorial much appreciated
Keep up the good work... thanks 🙏🏻
UNDERRATED videogames developing channel.
You are a beast and surely deserve more views per video.
Thank you and greetings from Argentina.
Thanks!
If you get runtime errors, use the type TextMeshProUGUI instead of TextMeshPro. I've had errors for DAYS and the thing didn't work until I had the bright idea to use TextMeshProUGUI. Now it works perfectly.
That depends on what object you used when making the prefab. The UGUI version is the UI version whereas the normal one is a world space text object. Both of them work the same but you do need to use the same type in code and in the editor.
Hey thanks for the video, got yourself another subscriber :) I was looking for a way to get cool looking damage numbers in a JRPG combat system, and this works great with a bit of tweeking to encorporate different colours for diferent damage elements and the like. I'm very happy with the results.
You can even combine it with custom fonts to make it crazier ua-cam.com/video/nBcP7FaDPE0/v-deo.html
@@CodeMonkeyUnity haha nooo, why would you do this to me? I'm trying to stay focused on my development goals, I can't fall down a tangent... but it does look like it could be useful... I should probably watch it....
This is pure gold, i think this would benefit from the getcustomdir function of yor utilities, maybe some easing on the transition.
Thank you for this tutorial, it was very usefull!
But when I tried to Refference the pfDamagePopUp with the GameAssets Skript I got the ArgumentExeption: "The thing that you want to instantiate is null."
So I needed to get the refference with a workarround. Any Idea why this happened?
Because I really like the Idea of the GameAssets Skript to easily acces different refferences
The reference is in the GameAssets script which is attached to a object in the scene, drag the reference on there. That object is a prefab so make sure you update the prefab after you drag the reference.
You are missing the "Resources" folder. Put GameAssets prefab in there. it was not explained in this video.
This really confused me too. @SoulsElite kindly pointed out we're missing the Resources folder, but research into Resources points out that it shouldn't be used at all:
"3.1. Best Practices for the Resources System
: Don't use it." :(
From: learn.unity.com/tutorial/assets-resources-and-assetbundles#5c7f8528edbc2a002053b5a7
@@SoulsElite thx man
Just discovered your channel ! Quality content very well explained! Continuous like that!
Glad you like what you see!
Thanks for all the great content! I for one appreciate the reasonably fast pace your videos takes - this allows you to quickly go through and understand what gets done, then pause where you need to as you dig deeper. I am a Unity Newbie, although I've been coding (older languages, mostly not object oriented unfortunately) for many years. I am trying to adjust this demo to allow me to create temporary moving icons (images) on the UI - like a gold coin jumping smoothly from one place on the UI to another and then disappearing. I used RectTransform in place of Transform. The image gets created successfully within the UI structure by specifying the parent on the Instantiate call, and simple linear movement from point A to point B within X seconds is working already. I'm now trying to get some interesting "paths" built in, still need to see how I will parameterize the Image to be shown, and I'm struggling to implement the "Destroy()" call without hard-coding the name of the object. any pointers on the Destroy call would be appreciated.
In order to Destroy all you need is a reference to the object so it depends on how you are creating and animating your icons.
If you're doing a similar pattern in the video where the icon moves itself you can do the same thing Destroy(gameObject);
If you're spawning them in sort sort of UI Script then that script needs a list of the currently active popups and call Destroy on them when it's time.
For some interesting paths you can either do like I did in the video and make it code based or you can also create a AnimationClip.
Do you have a Patreon or similar page for donations? I didn’t see one on the website.
Don't have a Patreon but if you'd like to support the channel you can pick up the Game Bundle from the website and play my games.
@@CodeMonkeyUnity Done!
I put like first blindly for cz I knw u always give good one 😂😍
Thanks!
Great video and explanation!
Thanks!
Well done CM. From a coder perspective nice, but I guess these things mostly are done with animation (moving, disappearing parts). Overall, thanks again for the great work.
Yeah the animation of the popup could certainly be done with a AnimationClip.
awesome method CM .. But I am curious that the same effect can be made with the UI Canvas sys ??
Thanks you! It was very helpful for me!
Great for me....learning game dev so doing platformer not straight 3d
If want to do 3D, some of the systems between 2D and 3D are similar. I started learning 3D and a lot of the systems are similar with minor changes to the syntax as it is (x,y) vs. (x,y,z)
@@indieprogress7170 yeah
I am facing issue that My popup is called to Hierarchy but it is hidden whether in 2d or 3d view of the scene window
Bro your chanel is like a holy grail for me
Glad to hear it!
Another great video. Thanks
If someone having Text not showing or disappearing after damage popup is spawned, this might help -
“If you are using a mixture of normal TextMeshPro objects and TextMeshProUGUI objects which happen to share the same material preset, this can produce this behavior as the MeshRenderer and CanvasRenderer systems are fighting over the ZTest on these objects.
Solution: If that is the case, the solution is to have a set of Material Presets for the normal text objects which are in worldspace and another set for the objects using the canvas system”
It gives me an error with the gameasset one
Create a folder names Resources, put your prefab named GameAssets in that folder
I find this very useful thx 👌
Very good turorial! I, however, think that the sortingOrder solution should be re-thinked. You will eventually (even though it might take a while) run into an integer overflow exception
Not a big deal. At some point a single group would be have wrong sorting order but it would fix itself.
However if you are concerned you can set it to 0 when there is no shown damage
In my case when I was following the tutorial step by step, I had to set 'disappearTimer' variable this way:
private static float disappearTimer;
instead of 'non static'.
Without being 'static', that variable was set to 1f in the first frame, and then suddenly to 0 in the second frame, then to 1f in the next one, and so on.
NICE zoom in on the text! (Make its snap and easier to see in Visual Studio)
Thanks! Trying out some new things.
Ppl trying to follow your guide but the speed is crazy and valuable step could be missed even using pauses
Dont worry about having to pause. Your goal should be to learn so don't worry if it takes you a while to follow the video, just make sure you understand it.
@@CodeMonkeyUnity Well, I got your point about implementation this (thanks for good explanation!) however I was curious what TextMesh settings you use to get such text design.. and it was not easy because of the speed :(
Everything seems to work fine EXCEPT getting the score to be where the mouse position is. I am in 3D and it doesnt seem to track its position. I have used the util.class and im not getting anything. Any ideas why this could be?
How are you getting the mouse position? It's a different method in 3D ua-cam.com/video/0jTPKz3ga4w/v-deo.html
I keep getting a null error due to the Game Assets, I have tried make sure everything is like how yours is but I still get the nullpointer exception, help please!
I have the same Problem. Codemonkey can you reupload the project?
MagicTimm I figured it out, you need to create a Resources Folder and then have the GameAssets Game Object within there, he was trying to call the folder Resources to load the GameAsset object.
@@exmarxgames Thank you very much !
Also always be sure to type if (_i == null) instead of if (_i = null). That was my problem :D
Dumb fail xD
@@exmarxgames thanks!
Nice tutorial! if u can help me, how can I do the same with a objectpool? to improve performance
You would just replace the Instantiate(); call with a function to grab an object from a pool, everything else would be the same.
Thanks so much!
Very helpful, thanks! :)
I haven't used TMPro, and based on your video it seems it is possible to use it without a canvas, just have the RectTransform in world space? Pretty neat, and probably more performant than having zillion World Space Canvases... but how about not having Canvas scaler? How would the text be scaling in this case? I understand this is demo, but do you use this approach in your own games? Thank you for the video like always!
Yeah I'm still new to using TMPro so not too sure how they're using a RectTransform without a Canvas, I think the RectTransform is simply translating the Width, Height and Pivots into normal Transform coordinates.
I haven't used TMPro in any of my published games since it has a bunch of issues when dealing with Asian languages, you need to create a atlas for each language and I haven't gotten around to figuring out how to sort that so Battle Royale Tycoon is using a normal TextMesh.
The text seems to be scaling solely based on the Main Camera so it works just fine like a normal TextMesh.
I wonder which video discusses the script for the game asset.
The GameAsset class? It's basically just a singleton, I covered it a long time ago unitycodemonkey.com/video.php?v=7GcEW6uwO8E
Hi nice Tutorial as always. Is there a Tutorial where u build the blood effect? I know there is one for the blood trail, but there u use the finished effect. Im asking more for the blood particle effect itself?
Haven't managed to do a video on that yet, it's on my list.
Essentially there's a giant mesh and every blood particle is a quad in that mesh that moves and then stops.
Hi. I have an issue with the opacity fading. The floating text moves up fine, however, it goes to transparent instantly and doesn't fade slowly. I have copied your code step for step. Any ideas?
Solved this by initialising the "textColor = textMesh.color;"
and "disappeartimer = 1f" in the Start function
Should also make a tutorial on a tutorial dialogue, where some text teaches the player to navigate through menus
This video is great! Helped me a lot!
Is someone have the link to the video explaining more about the GameAssets class ?
Its here ua-cam.com/video/7GcEW6uwO8E/v-deo.html
Thanks !! You are the best ♥️
@@CodeMonkeyUnity Thanks I was looking for this as well
I dont have sorting layer under extra settings.. When it shows up its behind everything. Mine says geometry sorting but it doesnt show my sorting layers to choose from, any idea why?
Thanks for the videos!
Oops I was using text mesh pro UI
I cant find the video where you explain the game assets singelton!
I made it here ua-cam.com/video/7GcEW6uwO8E/v-deo.html
Thank you!
No doubt one of the BEST unity teachers. Love it. Code monkey is the # 1 place to to..
I have a question. I followed the tutorial and even downloaded the project files to ensure I got every line correct. I do not have a enemy handler so I tried to use it with my own enemy script. Can you please show or explain how to set this up with an very simple enemy script?? I take damage when my bullets hit me, so I tried to put the code in there, I get error messages for the damage amount?? Please advice
What error messages? You just need to call the DamagePopup.Create(); function
Sorry about asking questions on an old vid. im just curious as to why you would make the text pop up a serialized private transform and not a public game object? is there a reason im not seeing?
If your variable is meant to be used only in a single class and not accessed from anywhere else then it should be private.
In order to keep your code clean but also allow dragging references in the Editor you can make it serializable.
public is essentially saying "this variable can be modified by any class anywhere" whereas private means "this variable is used in this class and this class alone, no need to worry about other classes modifying it"
Is there any reason to return damagePopUp in the DamagePopUp script instead of just returning null? Love the videos by the way!
On what function? The Create function does return the DamagePopup
@@CodeMonkeyUnity at 6:25 in the Create function
I wanted to do something like when the enemy is damaged it will show the damage popup as usual
however if the enemy get's the same amount of damage in rapid succession then it will reset the disappearTimer and print the damage followed by x and the amount.
For example: if enemy gets hit 30 times very fast for 2.5 damage it will print 2.5 x30.
Really want to know how to do this, can you make an updated tutorial if you are feeling up for it?
Not sure why, but when I finished up the 'Create' function, and I tried to do the damage testing, the pop-up failed to show up. I followed your instructions, but it just doesn't pop up.
Does anything show up? Make sure you're not instantiating a null object.
Pause the scene and look at the hierarchy, maybe you're spawning objects with a weird Z position.
@@CodeMonkeyUnity Nothing shows up at all. I also reset it to 0,0,0 and it doesn't pop up. Everything else before creating the 'Create' function worked the same as yours did.
Iam really struggling with the "GameAssets" class. I made it exactly how you did in this video but i just get an error "An object reference is required for the non-static field, method or property "DamagePopup.Create(Vector3, int)"
Sounds like you didn't make the Create(); function static
You are missing the "Resources" folder. Put GameAssets prefab in there. it was not explained in this video. Had the same problem.
@@SoulsElite Yes i watched his previous video and it fixed it all, thanks!
Hey CodeMonkey! Have your opinions on prefix files based on type changed over the years?
In terms of using the "pf" prefix, nowadays I normally just add "prefab" to the end of the variable name.
I started doing that because when people other than me are following a tutorial they might be confused as to what "pf" stands for so to avoid any confusion in the videos I just decided to switch that.
Hello, I am getting an error in update function, especially in this line : textMesh.color = textColor; you are implementing this at 10:50, the script is working and everything is all right, however I am getting 60 error messages per second in console saying : NullReferenceException: Object reference not set to an instance of an object. Could you help me fix this please ?
Sounds like you have your textMesh set to null, add some Debug.Log(); to find where it should have been set.
Also in your console click the button that says Error Pause so your game pauses when you get an error
@@CodeMonkeyUnity Ok I fixed it, problem was that my gameobject which was holding the script didnt contained TextMeshPro component.
Would you ever redo this tutorial in 3D space? This one doesn't translate well due to the fact that gameobjects are of different sizes so at further ranges you just can't read them
You could calculate the distance from the camera to the visual and use that to modify the transform.localScale
I'm kinda stuck. I have the exact same scripts and I keep getting: CS0246: The type or namespace name 'TextMeshPro' could not be found (are you missing a using directive or an assembly reference?)
I didn't have the library lol ... I missed the "using TMPro;"
The text is just not visible in my project, any idea what could it be? I have it set as the highest layer and it's visible in the Scene view, but not in the game view.
Check the Z position, it might be behind the camera, make sure it's on Z = 0
How did you get the text to draw without a canvas?
It's a World Text object, not UI Text, those are different classes
@@CodeMonkeyUnity ahh ok, thank you!
Amazing! Thank you!
Why do you use Transform for pfDamagePopUp instead of GameObject? We instantiate game objects and transform is just one of its components. Why does it work?
GameObjects and Transforms are pretty interchangeable because very Game Object has to have a Transform and every Transform has to be attached to a Game Object.
So since you cannot have one without the other, instantiating a Transform or a Game Object does the same thing, the difference is just the return type on Instantiate();
Thank u for the video
Hi, how to use this code if i use Canvas? Because if i trying use ur code its spawm, but spawn not inside canvas, so in that case i cant see any text, how to fix that?
Use TextMeshPro and not TextMeshProUGUI. The first one is a world component, not a canvas component.
If you absolutely need a Canvas then you can always use a World space Canvas and spawn that along with the popup ua-cam.com/video/Zwgj3mwOVlg/v-deo.html
@@CodeMonkeyUnity i tried do it to swap i canvas for world space, but it dosent help, text spawn not inside camera, not inside canvas
hey i wonder how you know wich code to use at wich situation? like how to learn/ what where to read the materials
It's all about experience, I've been writing code for 20 years and with Unity for 6 years so when I think up a system I already know what elements I'm going to need to make it work.
In this case I knew I could instantiate a prefab on top of the Enemy, change the colors of the TextMeshPro component and modify it's position and scale, then it's just the matter of implementing it.
The only trick is to keep writing code and making things, the more you write the easier it gets.
Thanks!
Pretty Nice! I've done a popup too in a 3d enviroment. My solution to have it over everything else was to have it's canvas in world space and 2 cams. One for the pop ups and the other for the game itself. Thing is the new URP dosent support camera stacking anymore. Any clean workaround? Had some folks telling to write a post process for this but feels like a overkill. Thanks in advance.
Camera Stacking has been added in the latest update!
Possible workaround would be something using RenderTextures
@@CodeMonkeyUnity oh you're right! Sadly I still can't have alpha to work on my popup camera anymore and it makes everything blue besides the numbers. Will check out RenderTextures. Thanks alot!
It was actually a bug in the version i was using that the Alpha in the Solid color background in the camera settings wasnt working. Updated it and it's working fine now. Thanks again for the response !
Is it better to do the effects in code or with animations?
Depends what you mean by "better", using an animation might be easier to manage and iterate on the animation
Would it not be best to use object pooling as you are going to have a lot of numbers appearing and disappearing over the course of a game?
Yes if you're going to implement this effect in a game with lots of shooting you should probably use object pooling.
@@CodeMonkeyUnity Ok thanks
can we use animations for effects
no matter how I follow your example I always get 'The Object you want to instantiate is null.' always around gameasset class. do you have any idea why? I followed the example directly.
The GameAssets class is placed on a GameObject on the scene and has a bunch of public fields, drag whatever reference is missing on there.
You are missing the "Resources" folder. Put GameAssets prefab in there. it was not explained in this video.
I have this error: ArgumentException: The Object you want to instantiate is null. When I try to Instanciate the textMeshPro object. Any idea? very thanks!
Make sure the prefab you are trying to instantiate is correctly referenced. Are you trying to instantiate something from a Serialized Field? If so make sure there's a reference in the script field in the editor.
@@CodeMonkeyUnity I had not created the resource folder xD. I'm very noob. Very thanks !!!
I want to have similar type of popup text which says "HIT" on first bullet hit and "HIT X 2" on second hit how to do that?
The popup is using a TextMesh so you can easily swap out damage numbers for text
There are lots of tutorials to make like for 2d top down shooter rpg like game
Shooting, enemy ai,damagable blocks, gun reload system, gun swap system etc.
There are lots of tutorials to make
Can you make any one of them plz?
How are you doing this without a canvas? Isn't a canvas required? I tried you technique and the text is invisible, nothing shows.
I'm using the Mesh based Text Mesh Pro component, not the UI one.
I've been having real problems with the singleton GameAssets Class,
Resources.Load... would always return null, no matter what I tried came up with this workaround
get
{
var result = Resources.LoadAll("");
if (_i == null){
_i = new GameAssets();
_i.pfDamagePopup = Instantiate(result[0].transform);
}
return _i;
}
any idea why I couldn't get the original "automatic" solution working?
The field inside the Resources.Load(); parameter needs to match exactly the object name. And it needs to be inside a folder named exactly "Resources"
Did anyone have a problem with this rendering on the Scene tab, but not on the Game/Simulator tab? I'm doing a 2D non-scroller for mobile. Canvas is 1920 x 1080 and my Main Camera is positioned at the bottom left-hand corner 0,0 as recommended by some other tutorials. Instead of emitting the damage from enemies, I have a button that I'd like have emit the text popups when clicked. The pop-ups show in the Scene tab, but not in the game tab. I had the prefab done in 20-30 mins and I've then spent 6+ hours trying to figure out what I've done wrong. Thoughts? Long time developer and android dev for a few years, but I'm new to Unity.
It shows up in Scene view but not game view? Perhaps it is spawning behind the camera? Check the Z position
Or perhaps it's spawning on a certain Layer that is not being rendered by the main camera
@@CodeMonkeyUnity Thanks for the reply! I found out that, as I was instantiating the prefab, I needed to assign it to a parent that was already on the canvas. Great video. You have me as a subscriber now.
thanks a lot for the nice video but sometimes you move mouse way too fast, that makes me rewind and slow down the speed just to see what you are doing. A good example is when you create a new sorting layer , in 07:14 - 07:19
I can not find the video with the game assets c# script, could you link it?
The static reference? It's this one unitycodemonkey.com/video.php?v=7GcEW6uwO8E
I can see TMPro in the Scene, but not in my Game view. I checked the layers, Z axis, position, viewed it in 3d to confirm it is in the front, not hidden behind any object. I don't use any other TMPro UI object, I don't have Canvas, so nothing should interfere here. Yet it does not show in the Game view. Any ideas?
Did you check the Sorting Order and Sorting Layer? I'm assuming your scene is in 2D so those are the fields that matter, not the Z position.
The background might have a higher Sorting Order and being rendered above the popup.
Other than that, just make sure the Z is in front of the camera so its not being rendered behind it. Usually Z = 0
@@CodeMonkeyUnity I figured it out finally. I was confused because none of the components had sorting layer, but default sorting layer was in fact being used by renderer. The text appeared once I changed sorting layer in my script. This should be in the inspector! Thank you
and how to use Code Monkey Utilities? just import and voila?
can i make it permanent like using System;?? so i dont have to do for each project?
When you import them you get a new Folder in your Project Files.
You can then use the full name like CodeMoney.Utils.FunctionTimer.Create();
Or add using CodeMonkey.Utils; at the top then just FunctionTimer.Create();
The utilities include all the source code so check that out.
Welp, trying to figure out the whole resources thing ended up screwing my project's directory so that's great
How so? You just create a folder anywhere called Resources, that's all
After downloading project files + utilities, new project in 2018.3.11f1 version, packages imported, press Play, and I just see huge sprites, and basically nothing work as expected.
Some errors are shown:
The referenced script on this Behaviour (Game Object 'Btn') is missing!
The referenced script on this Behaviour (Game Object 'Clickthrough') is missing!
The same happens with other tutorials, am I missing any step? Thank you.
I just imported the package into a completely empty project and everything worked fine.
There are some warnings since apparently I still had some UI objects from a previous tutorial but the scene still works.
What exactly do you see? Do you get any errors in the console or just the warnings? Does anything move in the screen?
@@CodeMonkeyUnity @Code Monkey Hi, check this video: ua-cam.com/video/gqQSh7bvk-0/v-deo.html Here you will see what I see when I create a new 2D project (release 2018.3.11f) and the package is imported, scene "Gamescene_Damagepopup" is loaded, and button 'Play' is pressed. Hope it helps. Sorry for the resolution. If you need further details, just let me know.
Hmmm what country are you from? I think I know what the issue might be.
I've just updated the package on the website, please download it again and try it out.
@@CodeMonkeyUnity I'm from Spain (I'm a computer scientist by the way) and I hope this fact has nothing to do with these errors :-)
Now it's working fine. Still a minor issue: in the 'Background' gameobject, Sprite -> Missing (sprite), so no background is displayed, only black solid color from main camera. Thank you for the corrections!
The background texture isn't included since I didn't make it, its a free texture from the Asset Store and I don't have a license to be able to distribute it.So the animations are working fine now? If so then the issue is related to how different countries use different symbols for floating points. Some countries use a Dot . and some use a Comma ,
It's a simple fix and something that is fixed in my own games but for these packages I forgot to add the fix directly to the animation system.
Thanks for letting me know!
Thanks!!!
thank you
Would love to see a tutorial on how to do some of the effects applied in JuiceFX programmatically in Unity.
Wasn't familiar with JuiceFX but upon seeing the videos it seems like a really cool program.
Those types of animations are certainly great for adding juice to your game. I'll look into it, thanks!
Just a question: can you use GameObject instead of Transform? Thanks.
Sure, every Transform has a GameObject and every GameObject has a Transform.
nice video
doesn't work not matter what I tried... maybe I've done something wrong... keeps getting Error: The Object you want to instantiate is null
You are calling Instantiate(); and passing in null as a parameter. Check where you're getting that parameter from, use Debug.Log to find what is null ua-cam.com/video/5irv30-bTJw/v-deo.html
so you can have a Text without canvas? am I right?
You add it as a component to an empty ... ok, managed to figure it out.
Canvas is only needed for UI objects, if you use World Text, you don't need a canvas, if you want to use UI Text you do need a Canvas ua-cam.com/video/Zwgj3mwOVlg/v-deo.html
I was really excited to find your channel but this is really hard to follow. I first needed to find how to import the packages, then I needed to figure out finding the same scene you used and then when I finally wanted to see what you're doing you're lightning fast. I can't even see what you're doing with the Unity Interface, this needs to be watched at 0.5x speed.
Do you mean when setting up the text object? I sped it up because the specific settings of the text object aren't really relevant to creating the popups.
Your game probably has a different style than what is shown in the video so the look of the popups will be dependent on what you're using it for.
Unfortunately this doesn't work if you are on a smaller scale game because you get grey boxes around all the characters :(
What grey boxes? Sounds like either your font size is too big or you just have no font assigned so you're just seeing empty quads. This element, like any element, can be scaled up or down
I cannot type that quickly....
I presume this only works for 2D as I cant get it to work in 3D, the sorting order doesn't work at all to keep the text on top.
For 3D you need to rotate it to face the camera, sortingOrder doesn't work in 3D, it's all based on Depth.
If you couldn't spawn the text where you click and you're in 3D project, try changing it into 2D one.
If you're wondering about how to get the mouse position it's a different method in 2D and 3D unitycodemonkey.com/video.php?v=0jTPKz3ga4w
What would the code be to be able to make the prefab spawn on top of my background?
Sorting in a 2D game is based on the Sorting Layer and Sorting Order
Not sure why but all my text just becomes invisible. It's there, but its invisible.
Check the Sorting Layer, Sorting Order and Z position ua-cam.com/video/5_BwFB-1dAo/v-deo.html
I followed until you actually implemented it on the aim handler script. I don't know how you created the GetPosition() function and passed it on .
It just returns the transform.position