Hey Guys,
so I’m trying to recreate Pong and want the ball to spawn in the middle with a desired start speed. The ball should start being faced in a random direction. However it should not face 0-30, 150-210 and 330-360 degrees. How can I do these exceptions? Here’s my code:
using UnityEngine;
public class Ball : MonoBehaviour {
public float startSpeed;
private Rigidbody2D rb;
void Awake ()
{
rb = GetComponent<Rigidbody2D> ();
rb.velocity = Random.onUnitSphere * startSpeed;
}
}