For who's having problem pulling component on 7:46, u should write public TextMeshProUGUI scoreText; instead of public text and than u will be able to pull component.
4:02 Brackeys adds a font by simply dragging into the project tab. If you are using TMP (Text mesh pro) you first have to create the font asset by going to Window>TextMeshPro>FontAssetCreator and then drag the font to the Source Font File. From there when you go to select the font to use you can find it in the pop out window as Brackeys does
"Only 9 minutes?" Psh, coding is easy... "Wait, let me copy that code real qucik and pause the video" "Oh shoot, I got some errors in my code, AGGH I DON'T KNOW HOW TO FIX IT, I SUCK AT PROGRAMMING and I don't understand any of the answers online.... OH I GET IT NOW" "Where is that button located in Unity? I DON'T KNOW WHERE IT IS... found it" "Hm... I have some errors again but its look correct, ohhh I misspelled Transform, it was transfomr, silly me" This should cover your reasons. ;)
For those using this as a reference or wanting to review specific parts of the lesson, here are some time-stamps of interest: 0:11: Improving project organization 0:34: Improving collision detection 1:27: Creating on-screen text 2:49: Scaling text with screen size 3:38: Downloading a new font and applying it to text 4:21: Getting player Z position 6:00: Updating on-screen text 7:45: Formatting text to display as whole numbers
I agree with this comment. I was just someone who didn't know anything abt making games other than scratch but I had a passion and now I'm working on my first game with only tutorials I found on this channel. Thank you so much.
For those who are using TextMeshPro instead of the legacy text, make sure to include the namespace for textmeshpro, which is TMPro (so include the line of using TMPro; at the beginning of your code). Also instead of using public text, use public TextMeshProUGUI
@@JellyGang680 In this tutorial, Brackeys uses legacy text as this video is 6 years old and I believe TextMeshPro was not a proper feature in Unity. Now, we can use TextMeshPro which I believe is more customizable and easier to use. For your score script, you need to add a using tag for TMPro, or else you will face errors.
Dude I know this is a very late comment but you're the best. After this tutorial specifically I used the methods from EVERYTHING you taught me and I made it so that the score stopped on a collision, its a small thing but i felt so proud that I did it myself from what i learned from you. THANK YOU!
@@reaperplays4170 On the collision script, add "public score theScore" as a variable and in the if statement, add "theScore.enable = false" and link up the text to "theScore".
I disable my ad-block for this channel as you do these videos pretty much for free, and you've motivated me in the past. Now I know a decent amount of C# and I got a little bit of experience with Unity thanks to your previous tutorials. Just nowadays I can't find the motivation to continue when I need it most :/
I'm glad to have helped :) For motivation I recommend forum.brackeys.com/ or this discord chat discordapp.com/channels/243005537342586880/243005537342586880 :) Good luck!
if you're doing this in 2022, there's an easy solution, you can still get the old text without using text mesh pro go into the game object tab at the top, then UI, then you should see legacy at the bottom. if you go into it you should see text. then follow the rest of the tutorial like usual, if you get stuck you can use the code below, or use the debug mode that brackeys showed using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public Transform player; public Text scoreText; void Update() { scoreText.text = player.position.z.ToString(); }
This guy gives free education man....... soo cool, online crash courses take $200 and the quality here is better than them. Hats off to u bruh, keep it up.
For anyone didn't set player start z position to 0. Make an int equal to the player start position like( int x = - 55;) Then ScoreText. text = (Player. Position. z+x). Tostring("0")
For those who don't have their starting position at Z 0, I made something to make it easier: 1. Add a public float variable called "initialZ" 2. Add a void Start() method (if you removed it) 3. Inside it, add "initialZ = player.position.z" (replace "player" with what you named your player) 4. On the top of the Update() method, add the following: "float newZ = plr.position.z - initialZ;" 5. Replace "player.position.z.ToString()" (where you change your text) with "newZ.ToString()" Your score will now start from 0 instead of minus something.
plz somone give me the full code for copy i have 2 error that saying: 1. Assets\Scripts\Score.cs(14,18): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Score.player 2.Assets\Scripts\Score.cs(14,38): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Score.initialZ' my code is: using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public Transform player; public Text scoreText; public float initialZ; void Start() { initialZ = player.position.z; } float newZ = player.position.z - initialZ; void Update() { scoreText.text = newZ.ToString();
BUG FIX: For all of you who got an exception "The namespace '' already contains a definition...": Check if you have some of the script files in the Assets folder as well as in the scripts folder. If so, make sure the ones in the Scripts folder are updated and delete the ones in the Assets folder. This might have happened if you had the scripts open while moving them to the Scripts folder. It worked for me, hope it worked for you :) i found a this on the ep 8 i hope it work
My method of learning is to watch the whole video through, and make notes without pausing it. Then attempting everything from memory, then use my notes to help or end up re-watching parts of the video I got stuck on. That way I feel like I'm doing most the stuff myself.
Another note: Just taking the Z distance works fine in this instance, but if you want to be able to be less constrained in your level design, you would use the distance between the starting vector and the current position, of course. The author of this video knows all of this, of course - I am just adding some things that might be useful to the audience.
Could you please tell us how it's done? My player is at a negative z position, so the score remains negative. If I could do what you said, I'd be able to fix it.
I Had Been Copying Every Other UA-camr's Video To Make My Video Game. But Because Of Your Course, I Can Make My Own Game Without Copying Anyone . thank you legend💖💖💖💖
I'm really enjoying following along to this tutorial! Thanks so much for making these series. If you are like me and in the part where we add in scoreText.text = player.position.z.ToString(); code and playtested, you may have had an error in the code. Something along the lines of "variable player of Score is not assigned". That is because the script affects the player and the text, so the Text AND the Player get the script. Just uncheck the score script from the Player in inspector and it's good to go. Don't be like me and scub through the video and restarting unity many times. Instead, google the answer next time :') Hope this helps!
Your tutorials are absolutely outstanding! I have learnt so much more about designing and coding games thanks to you! Keep the tutorials up! They are very appreciated. Thanks
if you are having trouble with adding score in Text (TMP) copy this: using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Score : MonoBehaviour { public Transform Player; public TextMeshProUGUI scoreText;
I am watching this during lockdown. I am now going to make a game, I also watched all his vids together and I think I can make it to the end of my game. Unity has taught me that 2d games are harder to make.
Alright, I see a lot of people have a problem where this error happens "UnassignedReferenceException: The variable Player of Score has not been assigned." And I got this as well. The error is most likely that you forgot to do this part 5:35 and you might have forgotten to do the same with the script. If you still have problems don't be afraid to reply to this comment.
i have a problem that so that the i dont have the "Player" variable in the "Score" script which prevents me from draging the player into there If anyone knows what i could have done wrong please reply with the solution i accidentaly closed unity but im going to open it so i can ctrl+c ctrl+v the error message edit:Assets\Scripts\Score.cs(5,14): error CS0101: The namespace '' already contains a definition for 'Score'
7:42 I am a newbie and I solved this problem my way. Surprisingly, my code works correctly. I decided to leave my decision inside the game, because my own terrible is better than someone else's and beautiful. By the way, here's my code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public Transform player; public Text scoreText; int convertPositionZ = 0; void Update() { convertPositionZ = (int)player.position.z; scoreText.text = convertPositionZ.ToString(); } }
-For anyone who wants the score to stop counting when you fail, just change the score script adding if (movement.enabled == true) { scoreText.text = player.position.z.ToString("0"); } -and dont forget the "public PlayerMovement movement;"
If anyone wants to disable the text, and then enable it on start up. Go into your Score script, make a Start() method and put score.enabled = true; This text controls the little checkbox besides the Text element, where you probably typed 250. Then, go to your text element, in the text object, and disable it, and on start up, it should appear. If you want to keep it enabled, and leave it there, obviously just change the text to 0.
Mech I need help and since this is an old video I though my best shot was to reply to someone, and you seem like you know what you’re doing. When I was trying to get the text to work it suddenly got really low quality and won’t go to a size over 27. I’m not sure how to fix it, please help.
@@skittlebread41 I completely forgot how to code, I'm sorry. I dropped off and I need to learn it again. I don't even understand what I'm saying in my own text.
in case anyone faced a problem where the player is SO fast and skip through every obstacle , its because you put the time step at 0.1 instead of 0.01. just in case :)
I decided to play test, and suddenly, my player/cube was able to go past the obstacles. It physically made contact with the obstacle, but it would just speed past it, and my movement would keep going on. Have you experienced this?
@@MichaelSalton go to edit at the top left and at the bottom it says project settings then there's a tab called time you go to and its called fixed timestep
These videos have been the greatest! Thank you so much for making them! You present stuff in a way that's extremely friendly to beginners and you manage to not linger on a bunch of small stuff at the same time. You are awesome!
My notes so you don't have to rewatch the vid. Make a folder for your scripts and materials. Occasionally, you’ll pass through objects. Under your Rigidbody component, set the Collision Detection to continuous. Then edit>project settings>time and set the Fixed Timestep to 0.01 This tells Unity to more frequently update our physics. For UI, create new object, UI, and text. Switch to 2D mode It creates a canvas, which is the game’s way of categorizing all UI elements. This canvas is 2D. Canvas will be in center of screen. Change Horizontal Overflow to Overflow so your text will keep going. Click on canvas and change UI Scale Mode from Constant Pixel Size (text doesn’t resize) to Scale With Screen Size. For more fonts, download them as a zip, then drag and drop into your assets. New script called Score using UnityEngine; using UnityEngine.UI;
public class Score : MonoBehavior { public Transform player; //location and rotation of an object named player public Text scoreText;
void Update() { Debug.Log(player.position.z); //Then drag player object into script. You can get rid of this line if you want.
scoreText.text = player.position.z.ToString(“0”); //allows you to change the text content. //player.position.z will throw an error that a float has to be converted to a string which is what ToString is for. ToString(“0”) rounds it up to the nearest whole number. }
Here we can see a good example of how to decide whether to use Update or UpdateFixed. UpdateFixed would have updated the score independently of the frame rate. But, because it probably doesn't make sense to update the scoreboard faster than we can draw a frame, it makes more sense to use Update. In this case, according to the Unity documentation, UpdateLate, I think, would be the most appropriate place, because we can or should probably draw our score after the frame is done drawing.
dude THANK YOU I was getting crazy trying to make a text prefab update a text on screen (surprise! it didn't work) so I watched your video and BAM. it works like a charm now. Thanks!
Thank you. You inspired me to learn to program and make games but most importantly you taught me how to do it. I hope you are doing fantastic cuz you are a really good person
Guys, for everyone that has problems with the text not showing when you're in game mode / maximize, in the text remember we put the horizontal to overflow? put the vertical too!
Save Often! Getting far enough along in the series that I want to try other things. Unity crashed on me and I lost at least an hour of work. (Could have been worse!) Lesson learned, Lesson shared.
I love tutorials like this, I come here to learn and it presents an amazing tutorial on the basics and i use the information to learn to make the game i want. I created a script that converts the distance to a percentage. My obstacles are differents weights and the game shows the heavier blocks to be darker which is calculated in a script, and i surprised myself by added a balanced jump mechanic. I urge everyone to experiment with these tutorials if you aren't already. It really shows that your learning to make a game without someone telling you exactly how to do it and it's an amazing feeling.
using UnityEngine; using TMPro; public class Score : MonoBehaviour { public Transform player; public TextMeshProUGUI scoreText; void FixedUpdate() { // Assuming you want to display the Z position of the player as the score scoreText.text = player.position.z.ToString("0"); } }
I can't think of a single time in my life when I even noticed a font or cared about it. (unless it was super retro pixellated or literally bleeding or something).
When i want to set time i cant do it even if i do it exactly same like the man in the video. I see your comment is not old much so can you please tell me how you did it? When i go to project settings and click on it, my setting looks really diferent. Did you have the same problem?
Your shadows, text, and everything is very sharp and clear, however, my Unity is rendering so low quality materials, shadows, I really don't know what to do!
This happened to me as well but noticed I accidentally dragged the playerMovement script down on the assets section. So it was telling me it already existed. Removed the dupe and I was able to drag it to score script.
Who ever needs help just copy this using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public Transform player; public Text scoreText; // Update is called once per frame void Update () { scoreText.text = player.position.z.ToString("0"); } }
Great series I learned more in this than a Udemy course. You just make it more understandable, even if they might have more details. For anyone who's number keeps the decimals, put in ToString("f0") . It was probably updated since this video, and the float means a decimal, so set the float to zero! ( As far as I understand it).
I downloaded the script because when I tried to type it out, I couldent get the player as a target for the score, and the downloaded script also doesnt work its says "A using clause must precede all other elements defined in the namespace except alias declarations" and idea whats wrong
i accidentally made everything the other way around and my score is negative. how do i fix it? Edit: scoreText.text = (player.position.x*-1).ToString ("0"); instead of scoreText.text = player.position.x.ToString ("0"); is the solution if it helps
Text' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'Text' could be found (are you missing a using directive or an assembly reference?)
You have to increase the forward force when you increase the fixed update because of something he mentioned in one of the previous videos: We are doing force * time.deltatime which means that as you check your frames more often, the speed will become slower(remember that time.deltatime measures the time since the last frame). This means that as you check your frames more often, each frame will increase the force less. But note that this relationship is not linear
IF YOU HAVE ANY BUGS vvvvvvvvvvvvvvvvvvvvv bug 1. TMPro if your using TMPro for text make sure to import TMPro instead of UnityEngineUI and also do as I do using UnityEngine; using TMPro; public class Score : MonoBehaviour { public Transform player; public TextMeshProUGUI scoreText; void update() { scoreText.SetText (player.position.z.ToString("0")); } } bug 2. if you using TMPro make sure that in unity when dragging the text into the script that its Text Mesh Pro UGUI instead of text bug 3. if your getting an error that says it cant find the player position or unknown variable scoreText make sure the player transform is also in the script I really hope this help because if I had this it would of saved me 2 hours!
Note about toString(); method: ToString(); is one of the many already existing methods of C#. ToString(); method is located inside a class specific to this kind of method. C# is know for this very aspect. A class, for those who don't know about it yet, is basically what you write code inside of since the begining of this project. The syntax goes as follow: public class ChildClassName : BaseClassName, InterfaceName, InterfaceName, blablabla { // Code block goes here } Note that you can only have one base class to support a class An interface is a template of another class you wish to implement inside ChildClassName in addition to its base class. No need to worry about this yet though. Back to the method ToString(); ... You can modify pretty much all of you can think of using this kind of method. Extremely usefull for math, lists, arrays, dictionaries, .txt files and so on. Here is a few exemple for the curious minds: * A field is base variable inside a class. The likes of: private int foo = 10; ** An Index is the location, from left to right, from 0, of an array. The likes of: string[] ArrayName = { "Value01", "Value02", "Value03" }; // value01 index = 0, value02 index = 1, etc. o Math.Sqrt(); // square root o Math.Floor(); // round up to lowest. 8.5 = 8 o Math.Ceiling(); // round up to higher. 8.5 = 9 o Math.Min(); // min value o Math.Max(); // max value o String.Join(“InbetweenEach”, value); // Call every value with first parameter in between each. o random.Next(minimum, maximum); // Randomize outcome of a number between arg1 and arg2 o ListName.FieldName.IndexOf(Value); // Return the index of specified value of a list o ListName.FieldName.Add(Value); // Add the specified value at the end of the list The list goes on.
*TO EVERY ONE WHO'S HAVING TROUBLE WITH THE SCORE* After you've written the code, check "text" and go to "Score(script)" then Drag "text" into scoreText, then hopefully it works.
int test = System.Convert.ToInt32("1000"); Debug.Log("string of 1000 - 400 =" + (test-400)); Displays "string of 1000 - 400 = 600" in console. You can also place some string variable in ToInt32(). Beware - if the string cannot be 'cleanly' converted to an Int32, it will throw an exception error. You can use a Try/Catch statement for best practice. There are similar Convert commands for other data types, which you can see once you type 'System.Convert.' into visual studio. You could also place the 'System' namespace in the 'using' statements of your script, then just use the Convert statement in the body.
For who's having problem pulling component on 7:46, u should write public TextMeshProUGUI scoreText; instead of public text and than u will be able to pull component.
i tried this but for me it says it couldn't be found what should i do?
@@tristanfp4887 at the top of the code
hello, still dosn't work... any other advice?
@@tristanfp4887 Thank you so much!!!
Thx
4:02 Brackeys adds a font by simply dragging into the project tab. If you are using TMP (Text mesh pro) you first have to create the font asset by going to Window>TextMeshPro>FontAssetCreator and then drag the font to the Source Font File. From there when you go to select the font to use you can find it in the pop out window as Brackeys does
Thanks a lot!
I can't even drag the text(TMP) into the Source Font File
Mad 'preciate
@@lickitysplickit no you gotta drag the font file (i know its late)
thanks so much
"Anything but Arial". Let's go with Comic Sans.
ah ah ah no please xD
bruh
0_o
How 'bout Papyrus?
same
Tutorial : "How can a 9 minutes video take 2 hours of your time to finish watching it ?"
"Only 9 minutes?" Psh, coding is easy... "Wait, let me copy that code real qucik and pause the video" "Oh shoot, I got some errors in my code, AGGH I DON'T KNOW HOW TO FIX IT, I SUCK AT PROGRAMMING and I don't understand any of the answers online.... OH I GET IT NOW" "Where is that button located in Unity? I DON'T KNOW WHERE IT IS... found it" "Hm... I have some errors again but its look correct, ohhh I misspelled Transform, it was transfomr, silly me" This should cover your reasons. ;)
Lmao
@@HealthyWC-2 Protip: save a backup of your script if you like to occasionally experiment like I do.
it's 9.07
@@ivonedev9658 who the fuck care
For
those using this as a reference or wanting to review specific parts of the lesson, here are some time-stamps of interest:
0:11: Improving project organization
0:34: Improving collision detection
1:27: Creating on-screen text
2:49: Scaling text with screen size
3:38: Downloading a new font and applying it to text
4:21: Getting player Z position
6:00: Updating on-screen text
7:45: Formatting text to display as whole numbers
thanks
life saver
Thanks it helped a lot
My player not moving, help!
@@rudrakshkumar6217 show me your code
Thank you for not only this video but also your all Unity Tutorial videos.
You're welcome ;)
@@Xmsnjeje evet yapabildim, google play store'da yayınladım fakat güncellemediim için oyunlarım silindi malesef.
I agree with this comment. I was just someone who didn't know anything abt making games other than scratch but I had a passion and now I'm working on my first game with only tutorials I found on this channel. Thank you so much.
My player not moving, help!
@@krky I dont speak turkish but ne denir?
For those who are using TextMeshPro instead of the legacy text, make sure to include the namespace for textmeshpro, which is TMPro (so include the line of using TMPro; at the beginning of your code). Also instead of using public text, use public TextMeshProUGUI
Thank You
wdym
@@JellyGang680 In this tutorial, Brackeys uses legacy text as this video is 6 years old and I believe TextMeshPro was not a proper feature in Unity. Now, we can use TextMeshPro which I believe is more customizable and easier to use. For your score script, you need to add a using tag for TMPro, or else you will face errors.
Thank you so much
I used this but I’m still getting an error does anyone know how to fix this?
Dude I know this is a very late comment but you're the best. After this tutorial specifically I used the methods from EVERYTHING you taught me and I made it so that the score stopped on a collision, its a small thing but i felt so proud that I did it myself from what i learned from you. THANK YOU!
I'm happy 4 you! :)
Noice
can you plz give the code i have been trying for 2 hours and i still cant get it done
@@reaperplays4170 On the collision script, add "public score theScore" as a variable and in the if statement, add "theScore.enable = false" and link up the text to "theScore".
well done bro
I watched this video 5 years ago when I was starting out learning to code. It's increadible how much the world has changed since then.
3:52 Red_Communist_Party.jpg
what
Lmao nice catch
HAHAHA nice one ^^
da fuq
Comrade Brackeys
He's OUR comrade
I disable my ad-block for this channel as you do these videos pretty much for free, and you've motivated me in the past. Now I know a decent amount of C# and I got a little bit of experience with Unity thanks to your previous tutorials. Just nowadays I can't find the motivation to continue when I need it most :/
I'm glad to have helped :) For motivation I recommend forum.brackeys.com/ or this discord chat discordapp.com/channels/243005537342586880/243005537342586880 :) Good luck!
A lot of jobs are using Unity, and C#. If you need motivation - think of your potential career.
@@Brackeys thank you for making these tutorials . can you make a tutorial on making a game like ninja stick but in 3d please.
@@Brackeys i dont know how to put z in the Debug.Log?
My player not moving, help!
if you're doing this in 2022, there's an easy solution, you can still get the old text without using text mesh pro
go into the game object tab at the top, then UI, then you should see legacy at the bottom. if you go into it you should see text.
then follow the rest of the tutorial like usual, if you get stuck you can use the code below, or use the debug mode that brackeys showed
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour
{
public Transform player;
public Text scoreText;
void Update()
{
scoreText.text = player.position.z.ToString();
}
Thank you so much!
you YOU ARE SAİNT
YOU ARE MY HERO!
Really, thanks!
you are a life saver
You're the man...
OMG, i just got assignment from my college to make an UI in Unity and you upload this video. Thanks B!
Also check out how he did the UI in the tower defense series, it looks really cool
This guy gives free education man....... soo cool, online crash courses take $200 and the quality here is better than them. Hats off to u bruh, keep it up.
Brackeys: The only UA-camr you don't have to crank up the playback speed for. These videos are really dense with material. I appreciate that.
For anyone didn't set player start z position to 0.
Make an int equal to the player start position like( int x = - 55;)
Then
ScoreText. text = (Player. Position. z+x). Tostring("0")
Thanks. What if I want to divide it. I'm starting on 40 and I want it to give me a point every 50 starting from z = 50
Thanks
@Wowkoby That mean something wrong in your code text make sure you wrote it correctly and you didn't miss semicolon or send me your code so i can help
For those who have the position with decimal number use float
@Alessandro Bova 7:32 in the script
For those who don't have their starting position at Z 0, I made something to make it easier:
1. Add a public float variable called "initialZ"
2. Add a void Start() method (if you removed it)
3. Inside it, add "initialZ = player.position.z" (replace "player" with what you named your player)
4. On the top of the Update() method, add the following: "float newZ = plr.position.z - initialZ;"
5. Replace "player.position.z.ToString()" (where you change your text) with "newZ.ToString()"
Your score will now start from 0 instead of minus something.
thanks
thank you for this
Thank you
plz somone give me the full code for copy i have 2 error that saying:
1. Assets\Scripts\Score.cs(14,18): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Score.player
2.Assets\Scripts\Score.cs(14,38): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Score.initialZ'
my code is:
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour
{
public Transform player;
public Text scoreText;
public float initialZ;
void Start()
{
initialZ = player.position.z;
}
float newZ = player.position.z - initialZ;
void Update()
{
scoreText.text = newZ.ToString();
}
}
@@ccaudiolibrary3309 you did not add the void update ()
Nobody:
Literally Nobody:
ME: Playing my own game for 8 hours straight.
i sympathize, and i kind of feel its that way because we're proud of our first project :)
same here buddy
me too xDDD
and the best thing is we are the "god" of our game, whenever we feel something needs to change, we change that
@@l_sx8722 yeh 😁
BUG FIX: For all of you who got an exception "The namespace '' already contains a definition...": Check if you have some of the script files in the Assets folder as well as in the scripts folder.
If so, make sure the ones in the Scripts folder are updated and delete the ones in the Assets folder.
This might have happened if you had the scripts open while moving them to the Scripts folder.
It worked for me, hope it worked for you :)
i found a this on the ep 8 i hope it work
omfg thanks soooo much ur a lifesaver
I wonder why I got that error, in the end i just figured out my script "score" was duplicated by accident. Thanks a lot man you saved me
Bro i will legit give you 10$ for solving that thank you
omg you saved me omg
Thanks a lot man
I might be 4 years late but after 5 useless guides on this topic you just made things so much easier thank you so much
For anyone following this tutorial in 2021 or until they change it, you can add text from GameObject(at the top) -> UI -> Text
ty bro you saved my code i was using the wrong type of text (text tmp)
Or help I can’t find text only mesh pro I can’t put it in the score scprit
My method of learning is to watch the whole video through, and make notes without pausing it. Then attempting everything from memory, then use my notes to help or end up re-watching parts of the video I got stuck on. That way I feel like I'm doing most the stuff myself.
Another note: Just taking the Z distance works fine in this instance, but if you want to be able to be less constrained in your level design, you would use the distance between the starting vector and the current position, of course.
The author of this video knows all of this, of course - I am just adding some things that might be useful to the audience.
Yeah he kinda mentioned that
How?
@@tomthebigman7481 Guess we'll never know...
Could you please tell us how it's done? My player is at a negative z position, so the score remains negative. If I could do what you said, I'd be able to fix it.
@@Rodri-gv8uf make the text = to the current position minus the starting position of the cube
I Had Been Copying Every Other UA-camr's Video To Make My Video Game. But Because Of Your Course, I Can Make My Own Game Without Copying Anyone . thank you legend💖💖💖💖
This man is a genuine hero to so many amateur coders
can you add a respawn mechanic in the next episode please
Working on it ;)
Brackeys yay respawn
how to scale from center on MAC?
He done it in a live for a 2D game i tried and it's work for this
without respawn / boundary the game can get cheesed :O
I'm really enjoying following along to this tutorial! Thanks so much for making these series.
If you are like me and in the part where we add in scoreText.text = player.position.z.ToString(); code and playtested, you may have had an error in the code. Something along the lines of "variable player of Score is not assigned".
That is because the script affects the player and the text, so the Text AND the Player get the script. Just uncheck the score script from the Player in inspector and it's good to go.
Don't be like me and scub through the video and restarting unity many times. Instead, google the answer next time :') Hope this helps!
thank you so much! this helped. the game worked but that error message was really annoying me, Thanks!
that's.... two years ago now you probs figured it out
This guy explains everything very comprehensively he is a cool good and awesome youtuber.KEEP UP!!
You have no idea how helpful you are... These tuts are gold!
Dani sent me here and i love these tutorials, thanks bracky
Your tutorials are absolutely outstanding! I have learnt so much more about designing and coding games thanks to you! Keep the tutorials up! They are very appreciated. Thanks
2:39 If you are using Text Mesh Pro, then disable "Wrapping" instead of enabling "Overflow"
ty this worked for me
if you are having trouble with adding score in Text (TMP) copy this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Score : MonoBehaviour
{
public Transform Player;
public TextMeshProUGUI scoreText;
void Update()
{
scoreText.text = Player.position.z.ToString("0");
}
}
what the using TMPro; do
@@rax0503 use to access text(TMP) object in our script cuz
public Text scoreText;
is for legacy text.
@@iamgod4u907 I understand now thanks a lot
You are a legend. Thanks!
@@4everbroke787 😅😂thanx
this guy helped millions of people to start game dev in the lockdown and corona peroid
yes
whenever my friends ask me how to do code, I immediately link them your channel. All of your tutorials are top tier.
keep up currently you are my best UA-camr
I followed this series for 4 consecutive episodes and now im getting game dev ads nonstop xD the "algorithm" works.
same here : )
when ever i expand my game view i cant move my character using A and D but whenever its in default view everything works fine
@@buritto8784 god thank you so much!
You can also use the combination Ctrl + P to start and that way you won't need to click on the screen
@@detyvitanova749 thank u
same issue!! How to figure it out?
@@adityarana7956 click on the game window or click maximise on play
I am watching this during lockdown.
I am now going to make a game, I also watched all his vids together and I think I can make it to the end of my game. Unity has taught me that 2d games are harder to make.
3D Games would make it the hardest to make for us. Have you finished making your game?
I've made Jumpy Cube game with the help of Brackeys videos. Such a nice guy to share all his skills with us.
Font Size: 69
I really hope that was intentional.
hahaha
so childfriendly
bruh moment
69 LIKES
@@Fancysand OMG BRUH
Alright, I see a lot of people have a problem where this error happens "UnassignedReferenceException: The variable Player of Score has not been assigned." And I got this as well. The error is most likely that you forgot to do this part 5:35 and you might have forgotten to do the same with the script. If you still have problems don't be afraid to reply to this comment.
tanks you helped me a lot
I'm having this problem, but i have assigned the player to the variable, im very confused.
I did everyrhing that you said and I still got the error
i have a problem that so that the i dont have the "Player" variable in the "Score" script which prevents me from draging the player into there
If anyone knows what i could have done wrong please reply with the solution
i accidentaly closed unity but im going to open it so i can ctrl+c ctrl+v the error message
edit:Assets\Scripts\Score.cs(5,14): error CS0101: The namespace '' already contains a definition for 'Score'
You are the best kind of human.
Brackeys is simply the best
For a second there, I thought this video was going to be about making a musical score for your game. This makes much more sense.
Is it only me who gets insane satisfaction when you try to guess the next step and it acctually works?
7:42 I am a newbie and I solved this problem my way. Surprisingly, my code works correctly. I decided to leave my decision inside the game, because my own terrible is better than someone else's and beautiful. By the way, here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour
{
public Transform player;
public Text scoreText;
int convertPositionZ = 0;
void Update()
{
convertPositionZ = (int)player.position.z;
scoreText.text = convertPositionZ.ToString();
}
}
well I have a problem converting the int format and your code helped it!! thanks you mate ^^
5:59 "So again we'll go into unity" *proceeds to open visual studio*
7:29 is the part we all come back to every month
The pure joy of seeing those numbers count up! =D
for me it counts down from -499. any pointers ?
am i watching a tutorial from 7 years ago? Yes
am i happy with it? Hell Yes
Thank you
-For anyone who wants the score to stop counting when you fail, just change the score script adding
if (movement.enabled == true)
{
scoreText.text = player.position.z.ToString("0");
}
-and dont forget the
"public PlayerMovement movement;"
you are a genius
1:25 THANK YOU that has been annonying me sonce Ep 1
Ret Zy oh GOD I THOUGHT I WAS THE ONLY ONE!!!
Since*
1:08 I put mine on 8000... it FLEW like a Kamikaze! 0_o
Loving this series so far, thank you so much 4 making it ^^
reenact 9/11
I had the same problem, then I realise I messed with the Time Manager without realising.
@@starman4346 LMFAOOOOO
@@xord1946 Well, glad you got it fixed tho! :D
These videos are great, nice quick pace but you seem to get the most important details in there. Can't wait to try this stuff out!!!
I also add the y and x position to score. Worked perfectly.
If anyone wants to disable the text, and then enable it on start up.
Go into your Score script, make a Start() method and put score.enabled = true; This text controls the little checkbox besides the Text element, where you probably typed 250.
Then, go to your text element, in the text object, and disable it, and on start up, it should appear.
If you want to keep it enabled, and leave it there, obviously just change the text to 0.
Mech I need help and since this is an old video I though my best shot was to reply to someone, and you seem like you know what you’re doing. When I was trying to get the text to work it suddenly got really low quality and won’t go to a size over 27. I’m not sure how to fix it, please help.
@@skittlebread41 I completely forgot how to code, I'm sorry. I dropped off and I need to learn it again. I don't even understand what I'm saying in my own text.
Hi! If you using the Text Mesh Pro, just add this on "using":
using TMPro;
then:
public TextMeshProUGUI scoreText;
god thank you so much man, was thinking why it wasn't working
You're the best
Helps a lot
How can I use Text Mesh Pro? Should I download it or is it included in the Unity editor?
i had this problem too
People who dont find "Text" but who find "Text meshpro" The text UI thing is in "legacy"
no prob3 people liking this + myself Xd
I think this was the easiest one to follow, I’m glad UI is easier than I thought
Once I will end this course I will 100% leave a donation on your website, this channel is extremely helpful
For those whose text is missing when font size is too big, just increase the text area
Thank you so much
genius thanks
appreciate that you speed up your videos by cutting the parts without speed. but I think it went too fast ;)
in case anyone faced a problem where the player is SO fast and skip through every obstacle , its because you put the time step at 0.1 instead of 0.01. just in case :)
I decided to play test, and suddenly, my player/cube was able to go past the obstacles. It physically made contact with the obstacle, but it would just speed past it, and my movement would keep going on. Have you experienced this?
i am having that problem, where do i go to change that value?
@@MichaelSalton go to edit at the top left and at the bottom it says project settings then there's a tab called time you go to and its called fixed timestep
@@roboticreviewer9159 It wont let me edit the fixed Timestep
I go to edit. Then hit project settings. then a tab pops up. then i go to time. then you cant edit anything.
These videos have been the greatest! Thank you so much for making them! You present stuff in a way that's extremely friendly to beginners and you manage to not linger on a bunch of small stuff at the same time. You are awesome!
ive been trying to make a game for so long but didnt know how to do it , then i found this, thank you.
Dude, you're amazing. Thank you for sharing this info.
My notes so you don't have to rewatch the vid. Make a folder for your scripts and materials.
Occasionally, you’ll pass through objects. Under your Rigidbody component, set the Collision Detection to continuous.
Then edit>project settings>time and set the Fixed Timestep to 0.01 This tells Unity to more frequently update our physics.
For UI, create new object, UI, and text.
Switch to 2D mode
It creates a canvas, which is the game’s way of categorizing all UI elements. This canvas is 2D.
Canvas will be in center of screen. Change Horizontal Overflow to Overflow so your text will keep going.
Click on canvas and change UI Scale Mode from Constant Pixel Size (text doesn’t resize) to Scale With Screen Size.
For more fonts, download them as a zip, then drag and drop into your assets.
New script called Score
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehavior {
public Transform player; //location and rotation of an object named player
public Text scoreText;
void Update() {
Debug.Log(player.position.z); //Then drag player object into script. You can get rid of this line if you want.
scoreText.text = player.position.z.ToString(“0”); //allows you to change the text content.
//player.position.z will throw an error that a float has to be converted to a string which is what ToString is for. ToString(“0”) rounds it up to the nearest whole number.
}
}
Here we can see a good example of how to decide whether to use Update or UpdateFixed. UpdateFixed would have updated the score independently of the frame rate. But, because it probably doesn't make sense to update the scoreboard faster than we can draw a frame, it makes more sense to use Update. In this case, according to the Unity documentation, UpdateLate, I think, would be the most appropriate place, because we can or should probably draw our score after the frame is done drawing.
Right on
dude THANK YOU
I was getting crazy trying to make a text prefab update a text on screen (surprise! it didn't work) so I watched your video and BAM. it works like a charm now. Thanks!
Thank you. You inspired me to learn to program and make games but most importantly you taught me how to do it. I hope you are doing fantastic cuz you are a really good person
I am a big fan of yours.
Can you teach to carry score from one level to next level,please
Guys, for everyone that has problems with the text not showing when you're in game mode / maximize, in the text remember we put the horizontal to overflow? put the vertical too!
yes thanks
my man
Save Often! Getting far enough along in the series that I want to try other things. Unity crashed on me and I lost at least an hour of work. (Could have been worse!) Lesson learned, Lesson shared.
There are two types of people that use computers:
1. Those who already lost data due to not saving
2. Those who yet have to
Ctrl+S is something that should be made second nature while working on projects. Saves me a world of annoyance when something crashes.
To anyone watching this in 2022, select "text legacy" when making the text. You would find it under UI --> Legacy --> Text
TYSM
I love tutorials like this, I come here to learn and it presents an amazing tutorial on the basics and i use the information to learn to make the game i want.
I created a script that converts the distance to a percentage. My obstacles are differents weights and the game shows the heavier blocks to be darker which is calculated in a script, and i surprised myself by added a balanced jump mechanic.
I urge everyone to experiment with these tutorials if you aren't already. It really shows that your learning to make a game without someone telling you exactly how to do it and it's an amazing feeling.
using UnityEngine;
using TMPro;
public class Score : MonoBehaviour
{
public Transform player;
public TextMeshProUGUI scoreText;
void FixedUpdate()
{
// Assuming you want to display the Z position of the player as the score
scoreText.text = player.position.z.ToString("0");
}
}
OMG dude you literally solved half of my problems
THANKS ....
I can't think of a single time in my life when I even noticed a font or cared about it.
(unless it was super retro pixellated or literally bleeding or something).
When i want to set time i cant do it even if i do it exactly same like the man in the video. I see your comment is not old much so can you please tell me how you did it? When i go to project settings and click on it, my setting looks really diferent. Did you have the same problem?
When he said create a score, I thought he was talking about music.
You stupid lol
Seriously!! Can you do another episode of Multiplayer FPS!
my game is getting better and better. thanks!
If your text is super blurry, make sure the font size is set to absolutely huge, then scale down the text using the scale tool
thanks alot
Your shadows, text, and everything is very sharp and clear, however, my Unity is rendering so low quality materials, shadows, I really don't know what to do!
same :|
It might be because the scale is too high in the game window. I changed that to 1 and mine is looking lots sharper.
When I tried to input the player into the score script under text there was no place to input it
I have the same thing help
You might have used Transform player instead of public Transform player
In script ,check it again
This happened to me as well but noticed I accidentally dragged the playerMovement script down on the assets section. So it was telling me it already existed. Removed the dupe and I was able to drag it to score script.
Who ever needs help just copy this
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour {
public Transform player;
public Text scoreText;
// Update is called once per frame
void Update () {
scoreText.text = player.position.z.ToString("0");
}
}
bro does it work
@@teddslidez works for me
Thank u so much :)
Thank you
Thank you!
Great series I learned more in this than a Udemy course. You just make it more understandable, even if they might have more details.
For anyone who's number keeps the decimals, put in ToString("f0") . It was probably updated since this video, and the float means a decimal, so set the float to zero! ( As far as I understand it).
absolutely love these turorials it teaches me the fundemantals and some code for future use even though i dont really know c#
3.35
I downloaded the script because when I tried to type it out, I couldent get the player as a target for the score, and the downloaded script also doesnt work
its says "A using clause must precede all other elements defined in the namespace except alias declarations"
and idea whats wrong
i accidentally made everything the other way around and my score is negative. how do i fix it?
Edit: scoreText.text = (player.position.x*-1).ToString ("0"); instead of
scoreText.text = player.position.x.ToString ("0"); is the solution if it helps
@@mungutribe9444 its the z [psition not x
youve put x position its z
Text' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'Text' could be found (are you missing a using directive or an assembly reference?)
Assets\Score.cs(6,12): error CS0246: The type or namespace name 'Text' could not be found (are you missing a using directive or an assembly reference?
I got the same message, try writing "text" with minus "t"
@@Andre-cx4ul minus t? Do you mean lower case t? I tried that too.
@@Nsix4 Instead of "public text scoretext" change it to "public UnityEngine.UI.Text scoretext"
@@somemore9784 Thanks for the help, but I ended up figuring out the issue. I had misspelled using UnityEngine.ui
You have to increase the forward force when you increase the fixed update because of something he mentioned in one of the previous videos:
We are doing force * time.deltatime which means that as you check your frames more often, the speed will become slower(remember that time.deltatime measures the time since the last frame). This means that as you check your frames more often, each frame will increase the force less.
But note that this relationship is not linear
Tip: Turn of gravity and you can float off the edge of the platform and dodge all the obstacles ;)
"We are gonna need to increase forward force a little bit"
*doubles it*
IF YOU HAVE ANY BUGS vvvvvvvvvvvvvvvvvvvvv
bug 1. TMPro if your using TMPro for text make sure to import TMPro instead of UnityEngineUI and also do as I do
using UnityEngine;
using TMPro;
public class Score : MonoBehaviour
{
public Transform player;
public TextMeshProUGUI scoreText;
void update()
{
scoreText.SetText (player.position.z.ToString("0"));
}
}
bug 2. if you using TMPro make sure that in unity when dragging the text into the script that its Text Mesh Pro UGUI instead of text
bug 3. if your getting an error that says it cant find the player position or unknown variable scoreText make sure the player transform is also in the script
I really hope this help because if I had this it would of saved me 2 hours!
mannnn THANK YOU SO FCKING MUCH!!!!!!!!!!!!!!!!!!!!!
Thank you!
thank you so much !!!
Stuck at 7:30 the canvas renderer isn't on the newest version
Note about toString(); method:
ToString(); is one of the many already existing methods of C#.
ToString(); method is located inside a class specific to this kind of method.
C# is know for this very aspect.
A class, for those who don't know about it yet, is basically what you write code inside of since the begining of this project.
The syntax goes as follow:
public class ChildClassName : BaseClassName, InterfaceName, InterfaceName, blablabla
{
// Code block goes here
}
Note that you can only have one base class to support a class
An interface is a template of another class you wish to implement inside ChildClassName in addition to its base class.
No need to worry about this yet though.
Back to the method ToString(); ...
You can modify pretty much all of you can think of using this kind of method.
Extremely usefull for math, lists, arrays, dictionaries, .txt files and so on.
Here is a few exemple for the curious minds:
* A field is base variable inside a class. The likes of: private int foo = 10;
** An Index is the location, from left to right, from 0, of an array. The likes of: string[] ArrayName = { "Value01", "Value02", "Value03" }; // value01 index = 0, value02 index = 1, etc.
o Math.Sqrt(); // square root
o Math.Floor(); // round up to lowest. 8.5 = 8
o Math.Ceiling(); // round up to higher. 8.5 = 9
o Math.Min(); // min value
o Math.Max(); // max value
o String.Join(“InbetweenEach”, value); // Call every value with first parameter in between each.
o random.Next(minimum, maximum); // Randomize outcome of a number between arg1 and arg2
o ListName.FieldName.IndexOf(Value); // Return the index of specified value of a list
o ListName.FieldName.Add(Value); // Add the specified value at the end of the list
The list goes on.
thank you u restored my faith in humanity
Getting a font shouldn't be too hard...
Wait, WHY AM I GETTING AN ERROR!?
*TO EVERY ONE WHO'S HAVING TROUBLE WITH THE SCORE*
After you've written the code, check "text" and go to "Score(script)" then Drag "text" into scoreText, then hopefully it works.
Thank you so much. I thought I did the code wrong but all I had to do was drag text in Score(script)
Score text doesn't show up next to where I put player
I'm trying to make a high score but I don't know how you convert a string to a int or float?
Please help thx
int test = System.Convert.ToInt32("1000");
Debug.Log("string of 1000 - 400 =" + (test-400));
Displays "string of 1000 - 400 = 600" in console. You can also place some string variable in ToInt32(). Beware - if the string cannot be 'cleanly' converted to an Int32, it will throw an exception error. You can use a Try/Catch statement for best practice. There are similar Convert commands for other data types, which you can see once you type 'System.Convert.' into visual studio. You could also place the 'System' namespace in the 'using' statements of your script, then just use the Convert statement in the body.