【发布时间】:2019-09-29 01:01:29
【问题描述】:
我有一个错误:
'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));
}
}
我想改变当前对象的坐标,与其他对象发生碰撞。
【问题讨论】: