private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == "Platform") { isJumping = false; Vector3 currentPlatformPos = collision.gameObject.transform.position; // 当前位置 // 下一个左边平台位置 nextPlatformLeft = new Vector3(currentPlatformPos.x - vars.nextXPos, currentPlatformPos.y + vars.nextYPos, 0); // 下一个右边平台位置 nextPlatformRight = new Vector3(currentPlatformPos.x + vars.nextXPos, currentPlatformPos.y + vars.nextYPos, 0); } }
这样子写就不用加trigger了, 还有就是做平台和人物碰撞框的时候要尽量小一点,我做的太大,导致点一下一次跳两个平台,找了大半天bug醉了