In Godot lesson Scripting Essentials, I can't get it to print

Attached is a picture of my code. For some reason it won’t print.

Hi Mark,

looking at that, its slightly different to what Bramwell has.

what we have here is the IF statement to check an input is pressed.
but the way it works, is that, if that input is true, then it will carry out the indented instructions below it.
so lines 10 and 11, are going to be done only if the button is pressed.

does your one print out the time once if the spacebar is pressed?
were the print statements printing to the console ok earlier in the lesson?

what Bram had was the time value being printed out at a different indentation so it runs at the same indentation level as the process
image

hope that helps a little, if its still not working as expected, just shout and we can try and get you back on track

A correction in the code, which I don’t know why it didn’t show was that the timer and print(timer) were properly tabbed to be under the IF statement. I did press space as well as Enter and still nothing comes out. There were no flags as to any errors in my coding.

Externally, in the Errors window, I notice that I got the following error message:
W 0:00:00:0895 _load_pipeline_cache: Invalid pipelines cache header.
<C++ Source> drivers/vulkan/rendering_device_vulkan.cpp:9028 @ _load_pipeline_cache()

Could this be because the Godot version I downloaded was the .net version that allows me to use C# also? Or is this caused by something else?

honestly Mark, i cant say for sure.
its mentioning Vulkan there.

just as a test if you dont mind, can you try switching the rendering mode from Vulkan to Compatability.
image

I go and grab the latest .Net version as well, ill go try and see what happens.

It was in compatibility mode. This time when I ran it, it gave no error messages at all but still did not print anything. I then set it to forward_plus rendering and restarted it and no printing. I set it back to compatibility and still no printing. I have no idea why its not working.

ive downloaded the .net version and seems to be ok.

just wondering is the script attached when running the scene?

if you could, zip the project folder up and if its small enough, send it over, or pop it online somehwere so i can take a look please.

I found the problem. For some reason, the code was not a child node of the player. By moving it from the assets to be a child of the player, everything worked fine. Thanks for your help.

1 Like

nice one, glad you found the fix for it and got you back on track :+1:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms