Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 语法:';x';是一个';变量';但用作';方法'; 公共游戏对象爆炸预制; 无效碰撞中心(碰撞其他OBJ){ GameObject explosionObject=实例化(explosionPrefab、otherObj.transform.position、Quaternion.identity)为GameObject; explosionObject(explosionObject,5f);_C#_Variables_Methods_Unity3d - Fatal编程技术网

C# 语法:';x';是一个';变量';但用作';方法'; 公共游戏对象爆炸预制; 无效碰撞中心(碰撞其他OBJ){ GameObject explosionObject=实例化(explosionPrefab、otherObj.transform.position、Quaternion.identity)为GameObject; explosionObject(explosionObject,5f);

C# 语法:';x';是一个';变量';但用作';方法'; 公共游戏对象爆炸预制; 无效碰撞中心(碰撞其他OBJ){ GameObject explosionObject=实例化(explosionPrefab、otherObj.transform.position、Quaternion.identity)为GameObject; explosionObject(explosionObject,5f);,c#,variables,methods,unity3d,C#,Variables,Methods,Unity3d,通常 方法声明: public GameObject explosionPrefab; void OnCollisionEnter(Collision otherObj) { GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject; explosionObject(explosionObjec

通常

方法声明:

public GameObject explosionPrefab;

void OnCollisionEnter(Collision otherObj) {
    GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
    explosionObject(explosionObject, 5f); <-- THE LINE GIVING ERROR
    Destroy(otherObj.gameObject);
    }
}
对该方法的调用:

void x() {
    // do something
}
变量的声明:

x();
变量的使用:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
您的代码

您声明了一个变量:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
但你可以像使用方法一样使用它:

GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
或者,您可以对您的实例和其他方法使用相同的名称,然后尝试更改GameObject实例的名称:

 explosionObject.MyMethod(explosionObject, 5f);

一般来说

方法声明:

public GameObject explosionPrefab;

void OnCollisionEnter(Collision otherObj) {
    GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
    explosionObject(explosionObject, 5f); <-- THE LINE GIVING ERROR
    Destroy(otherObj.gameObject);
    }
}
对该方法的调用:

void x() {
    // do something
}
变量的声明:

x();
变量的使用:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
您的代码

您声明了一个变量:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
但你可以像使用方法一样使用它:

GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
或者,您可以对您的实例和其他方法使用相同的名称,然后尝试更改GameObject实例的名称:

 explosionObject.MyMethod(explosionObject, 5f);

一般来说

方法声明:

public GameObject explosionPrefab;

void OnCollisionEnter(Collision otherObj) {
    GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
    explosionObject(explosionObject, 5f); <-- THE LINE GIVING ERROR
    Destroy(otherObj.gameObject);
    }
}
对该方法的调用:

void x() {
    // do something
}
变量的声明:

x();
变量的使用:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
您的代码

您声明了一个变量:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
但你可以像使用方法一样使用它:

GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
或者,您可以对您的实例和其他方法使用相同的名称,然后尝试更改GameObject实例的名称:

 explosionObject.MyMethod(explosionObject, 5f);

一般来说

方法声明:

public GameObject explosionPrefab;

void OnCollisionEnter(Collision otherObj) {
    GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
    explosionObject(explosionObject, 5f); <-- THE LINE GIVING ERROR
    Destroy(otherObj.gameObject);
    }
}
对该方法的调用:

void x() {
    // do something
}
变量的声明:

x();
变量的使用:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
您的代码

您声明了一个变量:

int x = 0;
x = 7; //write
y = x; //read and assing to another variable
但你可以像使用方法一样使用它:

GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
或者,您可以对您的实例和其他方法使用相同的名称,然后尝试更改GameObject实例的名称:

 explosionObject.MyMethod(explosionObject, 5f);

问题很清楚,让我们看看下面的代码:

GameObject game = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
explosionObject(game, 5f);

在这里,您已将
explosionObject
声明为
GameObject
变量,并且您的方法使用了相同的名称,这就是出现此问题的原因。更改变量名称或函数名称,您的问题就会得到解决。

问题非常清楚,让我们看看下面的代码:

GameObject game = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
explosionObject(game, 5f);

在这里,您已将
explosionObject
声明为
GameObject
变量,并且您的方法使用了相同的名称,这就是出现此问题的原因。更改变量名称或函数名称,您的问题就会得到解决。

问题非常清楚,让我们看看下面的代码:

GameObject game = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
explosionObject(game, 5f);

在这里,您已将
explosionObject
声明为
GameObject
变量,并且您的方法使用了相同的名称,这就是出现此问题的原因。更改变量名称或函数名称,您的问题就会得到解决。

问题非常清楚,让我们看看下面的代码:

GameObject game = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
explosionObject(game, 5f);

在这里,您已将
explosionObject
声明为
GameObject
变量,并且您的方法使用了相同的名称,这就是发生此问题的原因。更改变量名称或函数名称,您的问题就会得到解决。

那么您希望
explosionObject(…)得到什么
要做什么?这看起来像是一个方法调用-你想实现什么?你想调用一个方法吗?做其他事情吗?错误很明显。要更正代码,需要了解你希望实现什么。那么你期待什么
explosionObject(…)
要做什么?这看起来像是一个方法调用-你想实现什么?你想调用一个方法吗?做其他事情吗?错误很明显。要更正代码,需要了解你希望实现什么。那么你期待什么
explosionObject(…)
要做什么?这看起来像是一个方法调用-你想实现什么?你想调用一个方法吗?做其他事情吗?错误很明显。要更正代码,需要了解你希望实现什么。那么你期待什么
explosionObject(…)
要做什么?这看起来像是一个方法调用-你想实现什么?你想调用一个方法吗?做其他事情吗?错误很明显。纠正代码需要知道你希望实现什么。