Moved Unit animation logic into function