The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I'm following the Docs and stuck in the first part of Your First Game.
The instructions say to put this:

position += velocity * delta
position.x = clamp(position.x, 0, screen_size.x)
position.y = clamp(position.y, 0, screen_size.y)

under the _process function

I put it under the previous lines of code - not know for sure where it is supposed to go. I get an error of an unexpected token: identifier:position

Where should the position code go?

I have coded in Flash for many decades - pretty good at AS2 so this is a little different. It would be helpful in the docs to show what the code should look like before testing the game. I test the game and only get the Godot splash screen.

in Engine by (12 points)

1 Answer

0 votes

It seems likely you didn't indent those three lines. You're correct they go after the previous lines, but they still belong in the _process() function, so they must be indented.

by (22,191 points)

I figured out what was causing the problem. I had copied and pasted the code from the Docs which removed the Tab for the indent and put in spaces instead. When I deleted the spaces replacing them with Tabs it was happier.

Yes, that's a common problem when copying from web pages.

Just a tip: when doing tutorials, always type the code yourself. You will learn, and retain, much more than if you copy-and-paste.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.