Box collider with script : does not work

Hello
I have a problem with a box collider and I cant not find from where it comes from. I have searched in the forum but I am unable to find an answer.

I have created a scene with 3 cubes. They look like a tennis court.
The biggest one is like the “ground”, the second one is like the “net” and the last one is like the “ball”. (size similar with reality for all of them)
I have applied a box collider to all of them with the inTrigger tag unchecked.
For the “ball” cube, I have applied gravity and a script in c#.

When I run the scene, the “ball” cube is falling on the “ground cube” and doesn’t pass through it which is normal.

But when I move the “ball” cube, it does not stop on the “net” cube but pass through it and I don’t understand why, because it should rebound or stop on it

The code attached to the ball cube is the following one

using UnityEngine;
using System.Collections;

public class cubeposition : MonoBehaviour
{

    private float Zpos = 0; //position of cube
    private float a = 0; //accelaration m/s2
    private float s = 0; //speed m/s

    void Update()
    {
        Control();
        Calculation();
        Vector3 pos = transform.position;

        pos.z = Zpos;

        transform.position = pos;
        print(s);
    }

    private void Calculation()
    {

        s = a * Time.deltaTime + s;
        Zpos = s * Time.deltaTime + Zpos;

    }

    private void Control()
    {
        if (Input.GetKey(KeyCode.Q))
        {
            a = 10;
        }
        else if (Input.GetKey(KeyCode.A))
        {
            a = -10;
        }
        else
        {
            a = 0;
        }


    }

}

Thanks for any help

Setting a transform position directly bypasses collision. Either use forces instead or use Rigidbody.MovePosition.

–Eric

Thanks a lot Erich for your answer.
I completely missed that.
Regards