I’m trying to pass a Vector3 location to a method and am getting “Expression denotes a type', where a
variable’, value' or
method group’ was expected” as an error. Below is the gist of what I would like to understand.
Thanks for the knowledge in advance!
Vector3 myLocation;
myLocation = transform.position;
PrintX(myLocation);
private PrintX (Vector3 destination)
{
Debug.Log(destination.x);
}
You need to specify a return type for your method.
e.g.
private void PrintX(Vector3 destination);
1.) Your method doesn’t have a return type
2.) you can’t call a method outside of a method
3.) you can’t set myLocation = transform.position at compile time because it isn’t defined, you need to do that in Start:
Vector3 myLocation;
void Start()
{
myLocation = transform.position;
PrintX(myLocation);
}
private void PrintX(Vector3 destination)
{
Debug.Log(destination.x);
}