我有一个错误:
'GameObject' does not contain a definition for 'AddForce' and no accessible extension method
'AddForce' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
代码:
public float power = 500.0f;
GameObject var;
void OnCollisionEnter(Collision myCollision) {
if (myCollision.gameObject.name == "Cube") {
var = GameObject.Find("Cube");
var.AddForce(new Vector3(0.0f, 0.0f, power));
}
}
我想在与其他对象发生碰撞时更改当前对象的坐标。
三国纷争