You are making a class with a ;
and no { }
. This is how you are making the class:
public class CamShake;
A class should be declared like:
public class CamShake
{
}
I don’t know what you wanted to put inside it, but this is how you would do it by what I understand:
public class CamShake : MonoBehaviour
{
public void CamShake()
{
//something.
}
public GameObject muzzleFlash, bulletHoleGraphic;
public float camShakeMagnitude, camShakeDuration;
}
I also changed the public void CamShake;
to public void CamShake() {}
. Classes and methods both use { }
.
{ }
are used to tell the computer what to do inside a certain function or class. And ;
is used to tell the computer to execute that code. You don’t tell the computer to execute the method until it is called.
Declare a method:
void Method1()
{
//do something
}
Above, we aren’t actually telling the computer to do it, but we are telling the computer where to go when we call it.
Call the method:
Method1();
Note: this won’t do anything unless you have the method declared somewhere else in the class.
Right now, there is no point for making a class unless you have a method inside. This is because you could save the variables in the other script. I guess you could keep the class to be more organized, but it isn’t needed.
You may have not meant to write class
there. If you didn’t, comment what you were trying to do, and I will try my best to give you the correct keyword. Here is a list of the keywords.
solved i couldn’t fix ‘error CS1514: { expected’ [closed]