Welcome to the Unity forums, @nhattink01
Please review the Using code tags properly thread and update your question. Also, as a general rule, you’ll get better responses by starting a new thread to ask your question rather than “necroposting” – an unflattering term for posting something largely unrelated on a very old thread.
With that out of the way, let’s see what we can do for your question… Here are some simple ideas to try
- Add a Debug line as the first action of your try block. Confirm that you can see this message in your console.
- Confirm that you didn’t actually assign something to those two fields: Cylinder, and spawnPoint. Exception handling only triggers when something goes wrong, like these values not being assigned.
- Try adding a “throw new NullReferenceException()” inside your try block, just to confirm you can get something in your console.
Someone else might be able to comment on when Instantiate will throw exceptions. I don’t actually know what exceptions this method will throw, and the documentation isn’t helping me much.