Question by
snon200 · Mar 12, 2016 at 02:46 AM ·
unity 5programmingcollidersmesh renderer
Parsing error
hi, i get the following error in 2 scripts i tried and wanted to know whats wrong: "error CS8025: Parsing error", thanks.
void Start () { } void Update () { } void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == new "Player") { GetComponent(MeshRenderer).enabled = false; } }
void Start () { } void Update () { if (Input.touchCount == 1) { Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position); Vector2 touchPos = new Vector2(wp.x, wp.y); if (collider2D == Physics2D.OverlapPoint(touchPos)) { GetComponent(MeshRenderer).enabled = false; } }
Comment
when posting about errors, it's best to include the complete error message including line numbers.
the first of your errors is on line 11 of the first script - remove the word 'new'
is the second error the same>? try posting the complete script...
Best Answer
Answer by pekalicious · Mar 12, 2016 at 05:14 AM
Like gif said, you need to remove the "new" from if (other.gameObject.tag == new "Player")
so it's if (other.gameObject.tag == "Player")
And, since this is C#, you get component with <>
, not parenthesis. So change the calls to:
GetComponent<MeshRenderer>().enabled = false;