小编Ger*_*abó的帖子

"OnCollisionEnter()"中的Coroutine(WaitForSeconds())给出编译错误

我正在尝试制作一个平台游戏,我想在x秒之后恢复平台的重力.但它提供了一个无法使用的complile错误,因为void不是内部接口类型.我是个笨蛋,我迫不及待地继续我的项目.谢谢你的时间,我很抱歉我糟糕的英语.

 private void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.name == "Platform(Clone)")
    {
        numberOfJumps = 2;
        Debug.Log("Platform hit");
    }

    //Maake platforms fall
    yield return new WaitForSeconds(2f);
    collision.rigidbody.useGravity = enabled;
    yield return null;
}
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

1
推荐指数
1
解决办法
328
查看次数

标签 统计

c# ×1

unity-game-engine ×1