Added: 1 year ago
From: BurgZergArcade
Views: 36,408
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (171)

Sign In or Sign Up now to post a comment!
  • i cant put the script on my evil cube, there is no errors, it just wont let me

  • Is C Sharp better than JavaScript?

  • Comment removed

  • Great Tutorial ! Never tried C# before, but its going well, I've seen some other of your tutorials and they're easy to follow. Just a question... What is the script named "SuperSecret" for?

  • Why is it that we have to typecast maxHealth in AdjustCurrentHealth ?

  • This is great stuff. I recieved errors but only because i did somthing wrong. I have 0 expirence at any thing when it comes to game develoment, codeing ect ect. I have been playing around with unity for a few weeks now. I have the basics down pat . I am continuing to learn more of the advanced features but the codeing is where its all at in my opinion. Would some one tell me the best place to start learning C#? I just think it would take forever to learn to write code from watching these vids

  • If you finish this game, I am going to join as soon as possible and become the 'Pro' of the game.

  • I wrote the script as you did, exactly and recieved many errors, mostly that curHealth was not specified or supported, known with unity. whatever, something like that, along with others. Is the script you wrote not supported in the new 3.4.2 pro version?

  • why dont you save us all and upload scripts somewhere like mediafire??

    i just keep getting error messages like: parsing error or unexpected symbol...

  • Your computers HealthBar was nearly at 0 width too! :)

  • // Use this for initialization void Start () { HealthBarLength = Screen.width / 2; }

    It says me: Unexpected Symbol "Void" in class.... bla bla bla....

  • @boriswc97 check the line above it.

  • I have problem. I compilated and writed script as you but i can't see HealthBar :C I checked many times my code and it's identic as you. Please master help me!

  • I have exactly the same as the script.

    but when i try to change values after you did after 8:35, no other values change..

    the script stays:

    max Health: 100

    Cur Health 100

    Heath Bar Lenght: 0 after I save the scrpit

  • help error

    Assets/Scripts/PlayerHealth.cs­(36,31): error CS1525: Unexpected symbol `healthBarLength'

  • Quick Question is there anyway to make the healthbar appear above the targeted monster and if there is multiple only show on the targeted one? if there is would you mind showing me how?

  • I know this is a stupid question , but i am new to this, and i can't seem to copy it , lol

  • error CS1061: Type `UnityEngine.Rect' does not contain a definition for `curHealth' and no extension method `curHealth' of type `UnityEngine.Rect' could be found (are you missing a using directive or an assembly reference?)

    Help I am new to scripting

    Also another Error Is

    error CS1501: No overload for method `box' takes `1' arguments

    i cant figure it out

  • Hey i have an error where i have two gui boxes for my player, i do not have two scripts attatched or anything so i dont know what to do or what is wrong, can you help?

  • @AwesomeDude347 I have no idea what you did wrong.

  • say I want to make the enemy health bar invisible, how do I do htat?

  • quick question. mine keeps saying that there is an unexpected symbol "if"

  • @ASDrocksvlog sounds like you have a typo.

  • what is this Assets/Scripts/PlayerHealth.cs­(19,82): error CS1061: Type `UnityEngine.Rect' does not contain a definition for `curHealth' and no extension method `curHealth' of type `UnityEngine.Rect' could be found (are you missing a using directive or an assembly reference?)

    and this? Assets/Scripts/PlayerHealth.cs­(19,13): error CS1501: No overload for method `Box' takes `1' arguments

  • its "curHealth += adj"

    "==" will give you an error.

    II also had the same problem.couldnt really notice it

    hope this helped...

    (:

  • do i put this script in any of the folders in the hierarchy tab if so which one(s)

  • I don't Understand how to show this thing in "Inspector" from 4:38 (change hp property ) How I can do it ?

  • @MrPreslav

    In the Hierarchy window, select the first person controller (In this vid it's called Player), and the properties of it will appear on the right, simply scroll down to the "Player Health (Script) section, if it doesn't show you already, and you can adjust the health settings there. :)

    That's all you have to remember if you want to change the settings of something, make sure it's selected in the Hierarchy window :) Hope that helped. :D

  • but... i doesnt show me the health bar...:( now..

  • 3 Errors:

    Assets/Scripts/PlayerHealth.cs­(21,64): error CS0029: Cannot implicitly convert type `string' to `int'

    Assets/Scripts/PlayerHealth.cs­(21,21): error CS1502: The best overloaded method match for `UnityEngine.GUI.Box(UnityEngi­ne.Rect, string)' has some invalid arguments

    Assets/Scripts/PlayerHealth.cs­(21,21): error CS1503: Argument `#2' cannot convert `object' expression to type `string'

    How can I fix it?

  • @Drathine I replaced += with == (I'm not sure which one to use, because somehow my laptop shows your video bit blurry. Now all the errors are gone, but I got new one:

    Assets/Scripts/PlayerHealth.cs­(25,33): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

  • @Drathine the == operator will only make two things equal to eachother. Very important when you have loops that require a lot of else statements. +- operator will increment the number. If your telling the meter to initially start at 100 you will want to decrement down from 100

  • @MultipleSolutionsENT This is wrong. The == compares two things to see if they are equal. It does not make them equal. +- will just error. If you want to increment someone, then use ++ or -- for decrement. If you want to add someone to an existing value, then use +=, and -= to subtract from it.

  • Assets/Script/PlayerHealth.cs(­26,33): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

    please help i don't know whats wrong, i've checked and double checked everything

  • @IrishPolak7 You still have a typo in the code.

  • Can you help me?

    It shows the bar, but when I get hit, it doesnt get smaller, or it stays on maxheath

  • copied all the code and i havent actually got any script errors but now when i run the game it sets my max health straight to 1 seems to be only when i added the code for if you go below 1

  • @speedierone Well check if you accidentally didn't use the "greater than" symbol.

  • @speedierone You have some operators backwards

  • Assets/Standard Assets/Scripts/PlayerHealth.cs­(28,38): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

    What did i do wrong?

  • @kwynn7 Check your scripts. You have a typo somewhere.

  • @BurgZergArcade What is a typo?

  • @boriswc97 when you type something wrong, it is referred to as a typo - typographical error.

  • @boriswc97 typo = you write something wrong (like "liek", or "waht is wrong with my text?")

  • You sound like Tom Hanks!

  • fantastic logic! great tut :)

  • i did the same thing of you but my script got an error saying : error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement. I dont know how to fix it someone help please?

  • @bobleclown3 That's the same message I've been getting. I cant find any "grammatical mistakes" in the code. help...

  • my health bar dosnt get smaller :L

  • I really appreciate your tutorials. I was reluctant to use them at first, because most of them are in C#, but i think i should teach myself that language. THANK YOU!!!!!!!

  • I've added the script to player... there's no errors why isn't it showing up??

  • Comment removed

  • Comment removed

  • thanks a ton for these tutorials! I went through tornado twins and now that I got a basic understanding of UnityScript I wanted to learn C#, but so many youtubers would stop their tutorials after just the third or fourth video :( so thanks a ton! also for making them easy to follow lol.

  • hey im getting this and i cant figure it out

    Assets/Scripts/playerhealth.cs­(26,33): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

  • Super tutorial man took me abit of time to get the script right but after that it works Perfect :)

  • plz help

  • This is what dont understand... how can the erro be at line 30 when the script only has 21 o.O??

  • Comment removed

  • Comment removed

  • To people getting compiler warnings: Check if you have the semicolon ; on the end of the previous line.

  • how do you make those wierd looking brackets (sorry biginner) on the window's?

  • Hey nice work! But i did the first Part and it worked. But when i did Part 2 It didnt work it says Assets/PlayerHealth.cs(21,42): error CS0103: The name `healthBarLength' does not exist in the current context

    What should i do ? PLZ ANSWER

  • i still got a division by zero error

  • @NiicKMW2 no its not its surposed to be

    healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);

  • I always mistaken - for = since the screen is so small.

  • @Drillfire414 Make it bigger.

  • your computers health is low : P

    Thanks for the tutorials! Helps out a lot

    

  • @BBryandownes He doesn't get out much. Low constitution.

  • nevermind got it

  • Assets/Scripts/PlayerHealth.cs­(30,1): error CS8025: Parsing error

  • @scrbluegaming You have a typo, take a look at the line where the error occurs and also the lines above it.

  • WHY DOES I GET THIS ERROR?!?

    Assets/Scripts/PlayerHealth.cs­(10,13): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration

  • Nevermind I just forgot to set ; after healthBarLength

  • What dose float mean?

  • please peepz, test your codes, this works fine for me, and i am using a notepad. for coding. :3

  • @Tathagat8 lol, i agree :P

  • i found one of the errors! i didnt name it right!! yes! iv spent literally like 3 hours tryna solve this! btw thank u ppl for ur pateince (mispell) burgzerg thank you.

  • C:/BuildAgent/work/6bc5f79e0a4­296d6/Editor/Mono/GUI/ListView­Shared.cs:175)

    UnityEditor.ListViewShared+Lis­tViewElementsEnumerator.MoveNe­xt () (at C:/BuildAgent/work/6bc5f79e0a4­296d6/Editor/Mono/GUI/ListView­Shared.cs:368)

    UnityEditor.ConsoleWindow.OnGU­I () (at C:/BuildAgent/work/6bc5f79e0a4­296d6/Editor/Mono/ConsoleWindo­w.cs:422)

  • NullReferenceException: Object reference not set to an instance of an object

    UnityEditor.ListViewShared.Has­MouseDown (UnityEditor.InternalListViewS­tate ilvState, Rect r, Int32 button) (at C:/BuildAgent/work/6bc5f79e0a4­296d6/Editor/Mono/GUI/ListView­Shared.cs:180)

    UnityEditor.ListViewShared.Has­MouseDown (UnityEditor.InternalListViewS­tate ilvState, Rect r) (at

  • ok i followed more close and fixed a few errors however 2 keep popping up..

    The class defined in script file named 'playerhealth' does not match the file name!

    and i will set another comment for the next one..

  • The class defined in script file named 'playerhealth' does not match the file name!

    Assets/Scripts/playerhealth.cs­(10,12): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration

    Assets/Scripts/playerhealth.cs­(24,17): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

    sorry if this is getting annoying.. im kind of new and know nothing.. im tryna fix errors and occasionally i do but still..

  • AN AD LASTED FOR 5 MINS AND I COULDNT SKIP D:

  • thank you xD. Great Tutorial

  • I need Some help. When i play when i decrease my health even the largest or tiniest bit it still shows the 100/100 can you please help me, anyone?

  • Can you type down the script for me its getting errors....

  • it shows both health bars in the same place how can i change this

  • Mannnnnnnnn I have a ver big problem, maybe it sounds a joke but its not. In this tutorial, in finish, you copy the Script File called PlayerHealth and rename it to EnemyHealth, HOW YOU COPY ITTTT :(

  • @RaYTraceur

    Okay I have already discovered it by my own way, but anyway for newbies is important...

    To copy the file you need to press Ctrl + D

  • Shouldn't the last if statement in the adjustCurrentHealth method be if(curHealth < 1) curHealth = 1;? because curHealth is the denominator and not maxHealth. For example if curHealth reaches 0, maxHealth/curHealth is 100/0 which would give us an error.

  • this is just crazy in monodevelop it finds no errors but in unity it says: Unexpected symbol `void' in class, struct, or interface member declaration

  • @chrilledk8 are you sure u made c sharp or java script ?

  • @chrilledk8 so? have u find the solution?

  • @TheMihaibogdan hmmm....kinda havent been in unity for a while and......cant even remember i watched this srry ^^

  • My Health Bar isn't displaying HELP!!!

  • @CarnageBunny make sure the function is called OnGUI and not something like OnGui.

  • @CarnageBunny You may need to drag the script and attach it to "player".

  • @CarnageBunny Dude i had the same problem so here is the answer to all your trouble:

    1) dragging the script to Player (in hierachy) within Unity

    2) right-clicking PlayerHealth under scripts and choosing Reimport

    ( 3) Make sure you spell everything correctly )

    Good luck!!

  • @CarnageBunny

    drag the healthbar code into the player 

  • @CarnageBunny Same here

  • i have also done this with both the EnemyAI one and it still gives me the complier error.

  • i keep getting all complier errors have to be fixed before you can enter play mode, i keep retyping it over and over, and then scanning it over and over to find what i did wrong, and i cant find anything wrong.

  • I have a problem at "curHealth +- adj;" do you know dow to fix it?

  • I have a problem at "curHealth +- adj;"

  • @morderca3121 me too

  • Hi, i don't know why my scripts get an error in the following part curHealth ++ adj;

    it says "Only assignment, call, increment, decrement, and new object expressions can be used as a statement C:\Users\Zelda-Maniack\videoga­me\game1\OrbS\Assets\Scripts\P­layerHealth.cs 31 22 OrbS"

    and also " ; expected" all in the same line in the "adj" var... I checked and I'm 100% sure that i didn't forgot any ;

  • @zstudioft try curHealth += adj.

  • ihave nochos

  • 31, 34 unexpected symbol curHealth what do i do curHealth is a variable

  • i hate csharp i prefer javascript but if this tutorial will take about 21 hours to finnish its probably worth it

  • @basketballdude138 I have never met anyone that has taken the time to learn c# that wanted to go back to javascript.

  • @BurgZergArcade He speaks the truth! Once you switch to C#, you'll never want to go back.

  • Your a genius. Thanks!

  • @NiicKMW2 Check the line above it.

  • My enemy health script refuses to compile. help?

  • @reaverdeath9999 It still has errors. Fix them first.

  • @reaverdeath9999 thanks again!

  • It says I have a parsing error in this code but i am pretty sure it is right...

    void Start ()

  • @reaverdeath9999 chances are you forgot a ; at the end of the line before it.

  • @BurgZergArcade ok, thanks!

  • @BurgZergArcade still doesnt work, even though i added the ;

  • @BurgZergArcade The healthbar is very long and i tried to change Healthbarlengt but it doesnt work(sry for bad english)

    

  • @BurgZergArcade And when i try to change it in the game i cant change the number 53900

  • @BurgZergArcade oh i fixed it but there is 1 more problem when i change maxhealth the health bar changes but when you do it the healthbar changes if you do cur health(sry for very very very very poor english)

  • How do you fix that?:

    Assets/Scripts/PlayerHealth.cs­(25,49): error CS1525: Unexpected symbol `adj', expecting `)', `,', `;', `[', or `='

  • why does this happen ? Assets/EnemyAttack.cs(39,28): error CS1061: Type `PlayerHealth' does not contain a definition for `AddJustCurrentHealth' and no extension method `AddJustCurrentHealth' of type `PlayerHealth' could be found (are you missing a using directive or an assembly reference?)

    heres my code public void AddjustCurrentHealth(int adj){ curhealth += adj;

  • @kickass465 You have 2 different spellings for AddJustCurrentHealth. Make sure you use the same capitalization.

  • thankyou sorry for the trouble

  • ive fixed my parsing errors but now it sais this :

    Assets/Scripts/PlayerHealth.cs­(29,22): error CS0103: The name `adj' does not exist in the current context

    and here is a bit of the code:

    public void AddJustCurrentHealth(int odj) { curHealth += adj; healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);}

    }

  • @5seaton4 You have it called odj when you declare it.

  • how do you fix parsing errors

  • @5seaton4 parsing errors are generally just typos. perhaps missing a ; at the end of a statement.

  • can someone tell me wats wrong with this line

    public void AddJustCurrentHealth(int odj) {

    it sais this error Assets/Scripts/PlayerHealth.cs­(23,13): error CS0116: A namespace can only contain types and namespace declarations

  • @5seaton4 The line looks fine. The error message would seem to indicate that you might have an extra } right before it. Check to make sure that your {} are properly paired up.

  • @5seaton4

    public void AddJustCurrentHealth(int adj) {

  • Hey, tiny bug fix. Currently, curHealth CAN go below zero very briefly, because the test to make sure curHealth isn't below zero happens, then the test to make sure it's not above maxHealth, then the test to make sure maxHealth isn't below 1. The order of the tests is important.

  • @legendarylugi Ah, good catch. To be honest, we can get rid of the part that checks the maxHealth as there is no way to currently lower maxHealth, or you can just move the maxHealth check first.

  • @BurgZergArcade yup. I was trying to make another post saying "put the maxHealth check first and it will work" but youtube wouldn't let me submit it for some reason.

  • so is using C# easy to switch to from Javascript? i know little in either but what i know and use most is JS.

  • @Mattchu1995 I find the syntax of both languages very similar. The only real difference is that C# has a bit more structure around its code.

  • your tutorials are awesome and easy to understand... how can i change the color of the health bar and make it regenerate... (Thumbs up) looking forward for your next tutorial...

  • @DragneelSlayer we will be covering how to change the appearance in the next tutorial, and regeneration shortly after that.

  • @BurgZergArcade looking forward to it.. oh can you make a tutorial on when i press the w key in the keyboard the character will run and play the animation run made in blender and when i stop pressing it the character will play the idle animation...

  • @DragneelSlayer We will be looking at those topics when we get to animations. If you want to work ahead, thane a look at the animation system in unity.

  • @BurgZergArcade thanks for the tip, i made it though its not that realistic...can't wait for next tutorial...

  • I have a model you can use if you want :), its already rigged and has a walk, idle and basic slash animation, would actually be nice if i saw it being used in your vids to help other people out on setting up animations in unity too. It's a .blend file, if you want it just pm me and i can link ya a download for it :)

  • dude you have helped me so much please dont stop your way better than tornadotwins

  • @xBryanTechx TornadoTwins and I have different demographics. He caters more to the introduction to game development, where I tend to be more of the intermediate level.

    I think both of us have a niche on tutorials for Unity3d :)

  • @BurgZergArcade idk i understand yours more when it comes to scripting i like the pace you work at and you have certainly helped me and dont stop :D cause i have a great idea for this game in unity

  • @xBryanTechx Well I am glad you find them useful. We will be looking at using interfaces later on to implement multiple inheritance in C#. This will be the way we are going to control how our character moves, as well as the mobs.

    The basic way that it works is, you have a method in your character class and your mob class called MoveForward(), but both do the exact same thing, but differently. For instance, your character moves with the keyboard, but your mob moves with some sort of AI.

  • @BurgZergArcade yea my next goal is to model a character xDDD i dont know how lol im used to map modeling etc.

  • @xBryanTechx I can model fine, but my texture creation has room for improvement. Pretty much anything more detailed then a gingerbread man is out of my skill level for now... lol

  • @BurgZergArcade lol texturing is my greatest strength but i am gonna practice modeling humanoid stuff but um yea im gonna quit spammin your vid with these useless comments please pm me

  • @dzafo88 We will be revisiting the HUD (healthbars, as well as other on screen displays) in later tutorials. The first few tutorials in this series was to get people use to the basics on using C#. Now that we are heading in to Object Oriented Programming (OOP), we will start to look at how we can separate the health bar from the evil cubie and have it display only what we have targeted, when we have something targeted.

  • @BurgZergArcade cool, cant wait till then...anyway thx alot again for these great tut series, very easy to follow..im currently on tut 5a :D

    btw, im a hobby 3d artist.. i could make us some real enemys like a fire golem or something else, to replace the "eavil cubie" if u like..

  • @dzafo88 Thanks and glad you like them. Sure some models would save me some time creating them myself. All that I ask is that they are available to everyone that is following along with this tutorial series to use for educational purposes.

  • @BurgZergArcade Sure, no problem, i ment it to be free..

    ill see what i can do, and ill send u a massage when i finish..

    if u like them u can add it on your site ( I dont have any) so it can be available for evryone.. anyway we`ll deal wit that later

  • @dzafo88 Np. Let me know when you are done then.

  • @dzafo88 Really nice of you, I'm sure this tutorial series will be awesome :D

    And great job BurgZergArcade, thanks for sharing this!

  • awesome tut very easy to follow :D cant wait for next video

  • @Dudehell1 I am targeting a Friday release for tutorial series. It will be fun to see what everyone ends up creating with this afterwords.

  • First of all thanks for the amazing work providing us with videos of Unity 3 beta.

    Second, awesome work with this tutorial, looking forward to see the rest of the series :)

  • @septien Thanks. It should be a fun little project to work on.

Loading...
Alert icon
0 / 00<