Hello I’m trying to create a pong game with two players, and I would like to know what code I can attach to my ball object to create a collision and bounce effect.
Ball.script
if (gameObject.name == “player” || player1)
{
What do I need to put in here???
}
Second question
When I start my game, the balls stays at the same position, what can I do to make the ball move to a direction so the two players can start playing or if I tab a button that the ball starts to move to a direction.
If you are using physics you can put a physics material onto the ball & set bounce to maximum so it reacts of the paddles correctly, for the initial bounce set a random direction as stated above, you can even put it at a random angle so it isn’t always going straight left or right at the start.
Also, if player1 is the name of the other player you probably need inverted comma’s around it as well in your if statement.