Added function to stop player when running into obstacles