How can automation testing be used for checking in game things?

At the moment I’m trying to grow my knowledge of the automation tool, so copying what is already in existence is what I am using for now to grow my knowledge - I would like to then be able to do things such as move my character, do different things and check everything possible with the automation tool.

The problem I am getting is no matter which example I look at, when I take across all relevant pieces of code to my tests file, I can never get it to work.