Under investigation in this paper is a (3 + 1)-dimensional generalized nonlinear Schrödinger equation with the distributed coefficients for the spatiotemporal optical solitons or light bullets. Through the symbolic computation and Hirota method, one- and two-soliton solutions are derived. We also present the Bäcklund transformation, through which we derive the soliton solutions. When the gain/loss coefficient is the monotonically decreasing function for the propagation coordinate [Formula: see text], amplitude for the spatiotemporal optical soliton or light bullet decreases along [Formula: see text], while when the gain/loss coefficient is the monotonically increasing function for [Formula: see text], amplitude for the spatiotemporal optical soliton or light bullet increases along [Formula: see text]. Directions of the solitons are different because the signs of imaginary parts of the frequencies are adverse. Based on the two-soliton solutions, elastic and inelastic collisions between the two spatiotemporal optical solitons or light bullets are derived under different conditions presented in the paper.