How to detect object hit another object?

I am news in Playcanvas.
I develop this small https://playcanvas.com/editor/scene/538811.
In this project box will be moved when press w or s.
My question is how can I detect box hit another object and can not pass through another box ?

Here is my code

var Script = pc.createScript(‘script’);

// initialize code called once per entity
Script.prototype.initialize = function() {

this.app.keyboard.on(pc.EVENT_KEYDOWN, this.keyDown, this);

};

// update code called every frame
Script.prototype.update = function(dt) {

};

Script.prototype.keyDown=function(e)
{

    if(e.key==pc.KEY_W)
    {
            this.entity.translate(-0.5,0,0);
        
    }

    if(e.key==pc.KEY_S)
    {
            this.entity.translate(0.5,0,0);
        
    }

};

The simplest solution is to use rigidbody component and collision component.

Some of the tutorials should help too: https://developer.playcanvas.com/en/tutorials/?tags=physics