In my game the player kills his enemies by shooting(its first person shooting game), and I wish to tell the player that he is going on the right direction(means any help like compass for user).
I am using Sprite to draw my compass nob and using sprite function to rotate nob as given bellow: -
I’m not sure I can help you out without knowing a little more about your project, but I’m pretty sure that issue won’t be caused by the script since it doesn’t affect the compass’s visibility.
But if you are using a similar setup to my example, check the settings on the second (GUI) camera. That might cause things to disappear if it has the wrong settings.
Try to narrow down where the issue is coming from, (is it a camera thing? or is it that the compass object is being moved or the renderer is getting switched off?). If it happens during development, that’s better because at least you can check to see if its still there in the hierarchy window.