Hello, In my beginnings with Unit and I’m making a game like Pong where two players opposite each other
hitting a ball , the players have rigidbody and the ball bounces off them … but I need the following effect :
That the ball passes through the player when it bounces from behind instead of bouncing off the player …
Any suggestions how i can do this ?
Thank you very much in advance!
arfish
2
Hi,
How about disabling the collider when the ball is behind the player, and is moving towards the player. Something like this:
If (ball.transform.position == behind the player && Vector3.Dot(ball.GetComponent<Rigidbody>().velocity.normalized, player.transform.forward) > 0)
ball.GetComponent<Collider>().enabled = false;
else
ball.GetComponent<Collider>().enabled = true;