edited to fit Unity engine