private void OnCollisionEnter2D(Collision2D other) { if (GameManager.Instance.isServing) { return; } if (other.gameObject.layer == LayerMask.NameToLayer("Frisbee")) { Frisbee frisbee = other.gameObject.GetComponent <Frisbee>(); frisbee.offsetToPlayer = baseMovement.offsetFrisbee; frisbee.SetPlayerPos(baseMovement.transform); frisbee.SetIsCaught(true); baseMovement.Frisbee = frisbee; baseMovement.LockMove(); } }
private void OnTriggerEnter2D(Collider2D other) { if (_gameManager.isServing) { return; } if (other.gameObject.layer == LayerMask.NameToLayer("Frisbee")) { _playerScore.AddPoint(scoreValue); _gameManager.TogglePopUp(); Frisbee frisbee = other.gameObject.GetComponentInParent <Frisbee>(); var character = isLeftSide ? _gameManager.lPos : _gameManager.rPos; frisbee.offsetToPlayer = character.offsetFrisbee; frisbee.SetPlayerPos(character.transform); frisbee.SetIsCaught(true); character.Frisbee = frisbee; character.LockMove(); _gameManager.isServing = true; } }