Game slows down

hello i have made a 2d tower defense game but its slowing down in a function ontriggerstay()…i got to know through the profiler …in that function its target the enemy and constantly checking its angle and according to that angle it sets its png and instantiate fire…please help me in optimizing this function…there are colliders on enemy and tower…

My guess is that instatiating every bullet for a machin gun is killin your performances. Instead, you should instantiate every bullets, preferably in the editor, and use those repeatedly => You need one, set it visible at the correct position, add force, once it touches something make inactive again etc.