It's unlikely that you were hallucinating in this situation. Seeing a cockroach in the dark and then not being able to find it when you turn on the light is a common experience that many people have encountered. There are a few reasons why this might have happened:
Light Adaptation: When you wake up in the middle of the night and suddenly turn on the light, your eyes need some time to adjust to the increased brightness. During this transition, you might not see the cockroach immediately, especially if it scurries away quickly.
Cockroach Behavior: Cockroaches are fast and can move quickly when they sense light or movement. It's possible that the cockroach, being a nocturnal insect, quickly hid in a dark crevice or under furniture when the light came on.
Sleep Inertia: When you wake up suddenly, you might experience sleep inertia, which is a period of grogginess or disorientation as your brain transitions from sleep to wakefulness. This can affect your perception and response time, making it harder to spot the cockroach immediately.
Environmental Factors: It's possible that the lighting conditions or shadows in the room, coupled with the quick movement of the cockroach, made it challenging to locate.
Fears and Anxieties: If you have a fear of cockroaches or insects, your mind may have exaggerated the experience, making it feel more intense than it actually was.
Hallucinations are sensory experiences that occur in the absence of external stimuli, and they are generally not connected to reality. In your case, seeing a cockroach in the dark is a real visual stimulus, but it's normal to struggle to find it when the light is turned on suddenly.
If you have any concerns about your perception or are experiencing other unusual sensory experiences while awake or asleep, it's best to discuss them with a healthcare professional or a doctor to rule out any underlying medical conditions. However, in the scenario you described, it's more likely a common occurrence rather than a hallucination.