Apparently the guy shouted "I'm German!" and "**** foreigners" before shooting. (according to a news website I just read)
I imagine he was fuelled with hatred by groups spreading their hateful ********. No different to how ISIS influence people with their hateful ****. Ultimately there's somebody mentally messed up enough to go out and actually do something like this that these people influence.