Help please!
I know only a bit of C#
And of course, I am using C# and its a 2D project
using UnityEngine;
using System.Collections;
public class Destruction : MonoBehaviour {
var Destoyed = int;
// Update is called once per frame
void OnMouseDown (GameObject); {
Destroy (GameObject); {
RaycastHit2D;
}
}
In line 5⌠try âint destroyedâ instead. Also, you could just delete the line, because I donât see you doing anything with that variable, anyway.
In line 8, remove the âGameObjectâ inside the () brackets. OnMouseDown doesnât need a parameter
In line 8, remove the semicolon. Itâs not a statement, itâs a function declaration. Those donât have semicolons after them.
In line 9, why do you open a { bracket? Remove that.
In line 9, You are trying to destroy the class âGameObjectâ, which doesnât work. You probably want to destroy âgameObjectâ, which is the GameObject this script is attached to. Lower/Upper case matters in C#!
int Destryoed;
//or if you want add value at start
int Destroyed = 0;
//but it seems that you are checking if something is destroyed? so better to use boolean
bool Destroyed = false;
Itâs useful for working with third party code if you donât want to look up the return type of a method. Thatâs mostly syntatic sugar, but sometimes I get lazy. It can also insulate your code a little bit against implementation changes.
But yeah, on the while it wouldnât be a major loss if the keyword disappeared from C#. And for UnityScript users it would be a massive boon.
Actually, when I tried your solution @Taschenschieber I have 3 more errors, which 5 have gone.
ERRORS:
(7,30): Unexpected symbol â{â in class, struct, or interface member declaration
(8,26): Identifier expected
(9,1) Unexpected symbol â}â in class, struct, or interface member declaration
using UnityEngine;
using System.Collections;
public class Destruction : MonoBehaviour {
// Update is called once per frame
void OnMouseDown (); {
Destroy (gameObject)
}
using UnityEngine;
using System.Collections;
public class Destruction : MonoBehaviour {
// Update is called once per frame
void OnMouseDown (){
Destroy (gameObject);
}
}
This is how it should look. Go look through some simple unity tutorials to get a feel for the format of C#
Actually, there is another error that was not killed with the poison yet.
(9,1): error CS8025: Parsing error
using UnityEngine;
using System.Collections;
public class Destruction : MonoBehaviour {
// Update is called once per frame
void OnMouseDown () {
Destroy (gameObject);
}
using UnityEngine;
using System.Collections;
public class Destruction : MonoBehaviour {
// Update is called once per frame
void OnMouseDown (){
Destroy (gameObject);
}
}
Again, this is how it should look. Youâre missing the } on line 9, then another on line 10