Script not working

hello
print update is printing to the console after that space pressd is not i tried extract methodand genertate method for prcessinput still noyhing

Hi,

Have you attached your rocket.cs script as a component to the rocket GameObject? You currently have the lights GameObject selected in your Hierarchy so it’s not really possible to tell.

Some additional pointers for you;

  • Try to make sure you are consistent with the brackets and braces, at a glance it looks like you have an additional closing brace in your ProcessInput method, but actually they are just not aligned, but it wastes your time trying to work it out by counting them, and that of those that offer to help you :slight_smile:

  • You can use Edit > Advanced > Format Document to often tidy up common issues like this within Visual Studio rather than doing it all by hand if you prefer that.

    image

  • I would also recommend you get into the habit of Capitalising your class names, lowercase names are typically used for variables and this could lead to confusion later down the line. So, a rename to Rocket would be beneficial.

  • The warning with regards to line endings can be resolved in a number of ways, either by changing/correcting the template that Unity is using for new scripts, or, within Visual Studio by using File > Save […] As and then clicking on the down arrow next to the Save button;

    image

    In the Advanced Save Options dialog you can then set it accordingly;

    image

    Note: this would have to be performed once per file which can get tedious, so changing your templates could be easier going forward.

  • Finally, you can just copy/paste your code into the forum, this makes it a lot easier to read and gives those who offer to help you the opportunity to copy/paste chunks of your code back in a reply for you, without having to type out your whole script. Screenshots are however useful for details within the Unity editor, or perhaps error messages.

Hope the above is of use. :slight_smile:


See also;

Privacy & Terms