In which case it seems as though it should do just what you want: have object creation and deletion happen in a single task, with a variable to hold any created objects, the contents of which are then destroyed at the start of the task (thus removing those created in the previous run of the task). You might then have some variable modified elsewhere to signal the creation of the object in the task. The only problem that I see offhand is that you might find object creation delayed by a frame, depending on how you detect the case that calls for creation of an object.
I think adding and removing a collider to a traverser is slow. You’d be better of creating the ray once, and setting a mask that will exclude the ray from colliding with anything, then, when you fire a bullet, set the rays mask to collide with walls, monsters, players and things like that.