Cube bounces off wall

Hello!
I am making a game where a cube runs into a wall. I need the cube to just stay at the wall when it hits it, but instead it slowly starts to fade away from the wall, I believe from bouncing/
How would I fix this issue? Thanks.

Assuming you’re using Rigidbody, you can do

void OnCollisionEnter(Collision c)
{
  GetComponent<RigidBody>().velocity = Vector3.zero;
}

This will stop the object entirely when it reaches wall.

Make a new script for the cube and in MonoBehaviour, make a void OnCollisionEnter and put a name in brackets (I suggest “other”) like this:

//the rate at which your cube moves has a speed, so there must be a
//public float in your script for that variable (just call it speed or velocity). So
//just use that variable in the code
void OnCollisionEnter(Collision name)
{
   //Set the velocity of the cube to zero using its RigidBody
  //If it is hitting the wall from the x axis
  transform.position.x = //cube's X position when it hits the wall
  //If it is hitting on the z axis
  transform.position.z = //cube's Z position when it hits
}

Tell me if that works.