private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.GetComponent <BallView>() != null) { OnBallHit?.Invoke(); } }
protected void OnTriggerEnter2D(Collider2D other) { // return if collider not a ball if (!other.gameObject.CompareTag("Ball")) { return; } // update ball velocity var ball = other.gameObject.GetComponent <Ball>(); var ballVelocity = ball.speed + (ball.speedModifier * (ball.maxSpeed - ball.speed)); var ballReflection = GetReflectionVector(ball.transform.up).normalized; ball.SetVelocity(Mathf.Clamp(ballVelocity, ball.minSpeed, ball.maxSpeed), ballReflection); // dust particles if (dust != null) { var reflection = Vector3.Reflect(ball.transform.up, transform.up); dust.transform.position = other.transform.position; dust.transform.right = reflection.normalized; dust.Play(); } // notify listeners OnBallHit?.Invoke(ball); }
public virtual void Hit(Vector3 point, Vector3 normal) { OnBallHit?.Invoke(); }
/// <summary> /// Проброс события синхронизации отбития, вызванного RPC методом /// </summary> private void SyncHitHandler() { OnBallHit?.Invoke(); }