using UnityEngine;

public class Practical5 : MonoBehaviour
{
    public float stopAfterSeconds = 5f;
    private Rigidbody rb;
    private float timer = 0f;
    private bool shouldStopBouncing = false;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    void Update()
    {
        timer += Time.deltaTime;

        if (timer >= stopAfterSeconds && !shouldStopBouncing)
        {
            shouldStopBouncing = true;
        }

        if (shouldStopBouncing)
        {
            // Gradually reduce velocity to stop bouncing
            rb.velocity = Vector3.Lerp(rb.velocity, Vector3.zero, Time.deltaTime * 0.5f);
            rb.angularVelocity = Vector3.Lerp(rb.angularVelocity, Vector3.zero, Time.deltaTime * 0.5f);
        }
    }
}
