Question by
Jakemf · Oct 26, 2015 at 12:02 PM ·
scripting problemerroryoutube
Error From Youtube Tutorial
I am watching a YouTube tutorial series (https://www.youtube.com/watch?v=sxMHM_ONkI8&feature=iv&src_vid=qArKtZLwoA4&annotation_id=annotation_3957004373) In the video the person types the following code :
using UnityEngine;
using System.Collections;
public class Demo : MonoBehaviour
{
public int health;
void Start();
{
Print("Player Health is: " + health)
}
}
They compile the code wth no errors however when i try to compile it i get the following errors:
Assets/Scripts/Demo.cs(9,5): error CS1519: Unexpected symbol `{' in class, struct, or interface member declaration
Assets/Scripts/Demo.cs(10,32): error CS1519: Unexpected symbol `Player Health is: ' in class, struct, or interface member declaration
Assets/Scripts/Demo.cs(10,42): error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration
Assets/Scripts/Demo.cs(13,1): error CS8025: Parsing error
I would like to know why I get these errors and they do not and how to fix them, I am using visual studio as my editor if that makes any difference (which I don't see how it could).
Comment
Answer by Landern · Oct 26, 2015 at 01:12 PM
You have a semi-colon after declaring the Start Method, you should remove it as it is a terminator.
using UnityEngine;
using System.Collections;
public class Demo : MonoBehaviour
{
public int health;
//Removed ending semi-colon after void Start()
void Start()
{
Print("Player Health is: " + health); // also missing an ending semi-colon after Print
}
}
Also you should have a Semi-Colon after the print statement, see above.