Balls bounce off wall in different ways

I’m trying to make a game similar to Tank Trouble where if the player shoots a bullet, it will bounce off the wall, just like in this image:
alt text

I achieved this with the following code:

float speed = 3.8f;

void Awake()
{
    this.gameObject.GetComponent<Rigidbody>().velocity = transform.forward * speed;
}

private void Update()
{
    this.gameObject.GetComponent<Rigidbody>().velocity = transform.forward * speed;
}


private void OnCollisionEnter(Collision collision)
{
    if (collision.collider.tag == "Wall")
    {
        print("coll norm: " + collision.GetContact(0).normal);
        Vector3 v = Vector3.Reflect(bullet.transform.forward, collision.GetContact(0).normal);
        bullet.transform.rotation = Quaternion.FromToRotation(Vector3.forward, v);
    }
}

However sometimes when I shoot 5 bullets for example, some of them will take a different path after a bounce than others. The problem is obviously is with the way I make them bounce, but then I don’t see why they bounce in different ways. I should probably mention that the balls can not collide with eachother because their layer collision is disabled.

I’m a bit late to this but, if the ball slides along the wall, it can be because the velocity is not high enough to be thought of as an elastic collision. You’ll need to do this:

Project Settings > Physics2D and reduce the Velocity Threshold

Adjusting that value should allow you to get bounces every time…

You don’t need script for this.Add a physical material to the wall with 0 friction and Bounce 1.Should work.