Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unexpected Symbol curHealth

Discussion in 'Getting Started' started by badassgamer, Jul 23, 2015.

  1. badassgamer

    badassgamer

    Joined:
    Apr 26, 2015
    Posts:
    140
    got error on this script

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerHealth : MonoBehaviour {
    5.     public int maxHealth = 100;
    6.     public int curHealth = 100;
    7.  
    8.     // Use this for initialization
    9.     void Start () {
    10.    
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Update () {
    15.  
    16.  
    17.    
    18.     }
    19.    void OnGUI(){
    20.         GUI.Box(new Rect (10, 10, Screen.width / 2 / (maxHealth / curHealth), 20) curHealth + "/" maxHealth);
    21. }
    22. }
     
  2. FadiGames

    FadiGames

    Joined:
    Jul 23, 2015
    Posts:
    15
    It's just a missing comma before curHealth inside the GUI box
     
    badassgamer likes this.
  3. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    There's also a plus sign missing.
     
    badassgamer likes this.
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    @badassgamer I don't want you to take this the wrong way, but 90% of your threads could be solved by just gaining some general programming knowledge. And the only way to gain that is to try solving things yourself.

    The errors you get are extremely helpful. They tell you exactly where to look to fix the problem. If you don't know what the messages mean, Google that message (In this case, "unexpected symbol") and then look at the line and column where it's saying it happened and attempt to solve it.

    I'm assuming most of these scripts you're posting are adapted from stuff you've found elsewhere. Which is fine. But if you just keep posting your issues and having others tell you how to fix it, you'll never actually learn how to write your own code.
     
  5. badassgamer

    badassgamer

    Joined:
    Apr 26, 2015
    Posts:
    140
    llol no problem . i understand what your saying but i cant slove myself cause it is so hard . i dont even understand what each line does . so at the end i give up and start just typing the code that they type on tutorial videos and leave it. yes i know i should something about it. thats what thinking . if i still cant learn then i should move to visual scripting . unity3d does not has it and also i cant buy playmaker and so i either need to move to ue4 cause it has visual scripting. but if you want say something just say it cause i dont get anything wrong.i know you people are helping me . thank you for it
     
  6. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    Again... this is going to sound harsh... but if you believe learning code is too hard, you don't have much of a chance at success at making a game. And it doesn't even sound like it would be the enjoyable of a hobby, even. Making games isn't easy, and a lot of times, it's not even fun!

    Programming is just another language. You've mentioned English isn't your native language. You've picked it up fairly well, though, and English is a tough language to learn. A programming language is no different.

    Look for C# tutorials. I found this one by searching for "learn C# free online". You have to give it time, though, and don't give up because you ran into one thing you can't figure out. Programmers get paid well because we run into things every single day we can't figure out... and then we figure them out.

    I've never tried visual scripting, but I find it hard to believe any decent game has been made using it. C# itself is an abstraction of code execution... any further away and you might as well use GameSalad or something... :p
     
    Martin_H and badassgamer like this.
  7. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    http://unity3d.com/learn

    Work through these, they let you download the assets so you can watch the videos where they explain what they're doing & why & then you can do it on your own computer. Take your time, as you learn new things go back to the old ones you've finished & try to make small changes. That way you are starting with something that worked so if it stops working you will know the problem is in the new bit you added.
     
    badassgamer likes this.
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    A visual scripting language is still a programming language but with a slightly different form. The fundamental concepts will be the same. You have variables, branching commands (if, switch, etc), loops (do, for, etc), and so on. You're simply switching from lines of text to symbols wired together.

    If I recall correctly there was at least one project mentioned during the early days of Unreal 4, but I can't be bothered to dig around too heavily. I'm confident it is entirely feasible to do so as they've been progressively unlocking more and more of the APIs for use in Blueprint.

    http://www.gamasutra.com/blogs/Mark..._Making_A_Full_Game_Using_Unreal_Engine_4.php
     
    Last edited: Jul 23, 2015
    badassgamer likes this.
  9. badassgamer

    badassgamer

    Joined:
    Apr 26, 2015
    Posts:
    140
    Thank you all for reply but what gamesalad means?
     
  10. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    Martin_H likes this.
  11. sadsack

    sadsack

    Joined:
    May 27, 2015
    Posts:
    156
    start small and work your way up