Climate change poses a serious threat to the existence of many species. The combination of habitat fragmentation and increasing temperatures is of particular concern because it can alter demographic and population genetic processes, which may ultimately lead to extinction. Locomotion is very important in mitigating the negative impacts of these processes by upholding migration and contributing to random mating within and between populations. In the present study, a T‐maze, constituting a relatively complex laboratory assay, is used to investigate whether inbreeding affects the capacity to reach a food source in male Drosophila melanogaster Meigen 1830 (Diptera: Drosophilidae) reared at 20, 25 or 30 °C, respectively. The effects of inbreeding and crossbreeding are highly temperature‐specific. Strong heterosis for the ability to reach food in the maze is observed in flies developed and maintained at 30 °C, whereas inbred flies locate the food significantly faster than crossbreds when reared at 25 °C in four of six runs. No clear pattern is evident in flies reared at 20 °C. The results suggest that complex traits such as locomotor performance in a maze are highly informative in the evaluation and detection of inbreeding depression under different thermal conditions. The effect of inbreeding is most pronounced at high temperature, which is a characteristic of the conditions that many natural populations may have to face under climate change.