- Home /
Question by
davidbuckleyweb · Oct 31, 2020 at 06:09 PM ·
c#gamepong
Pong speed of ball incorrect and ball colliding with the line
The speed of my ball is not fast enough even though i have followed the tutorial here also its not starting off from the paddles as it would do in a game of pong.
https://www.youtube.com/watch?v=YHSanceczXY

Here u can see the panel inspector 
Here is my ball script
public class Ball : MonoBehaviour
{
public float speed;
public Rigidbody2D rb;
public Vector3 startPostion;
// Start is called before the first frame update
void Start()
{ startPostion = transform.position;
Launch();
}
public void Reset()
{
rb.velocity = Vector2.zero;
transform.position = startPostion;
Launch();
}
private void Launch()
{
float x = Random.Range(0, 2) == 0 ? -1 : 1;
float y = Random.Range(0, 2) == 0 ? -1 : 1;
rb.velocity = new Vector2(speed * x, speed * y);
}
// Update is called once per frame
void Update()
{
}
}
Also here is my line inspector as the line is stoping the ball from getting across to the other side i dont no why.

Comment
Your answer