I have a question about the 3D tutorial code

You can check “Complete PlayerController” from the following link
ttps://docs.cocos.com/creator/manual/en/getting-started/first-game/#complete-playercontroller

However, I get an error when I use this code.

I think the end of the source code should be “;” or omitted.
However, “.” but some of them don’t give an error. number type might be better.

Is this possible that the version of TypeScript changes depending on the version of cocose and there is no problem?
I am using cocose 3.8.2.

Do I need to modify the code? Is there something wrong with my environment?
Please advise.

Its absolutely a code mistake. Remove “.” or replace them.
And, the number literals in JavaScript can end with a period “.”

1 Like

Quick response! Thank you.
." but from now on I will only use “;”!

the code line private _jumpStep:number = 0. doesn’t get an error, because it lacks something, but still matches the coding rule.

the full code line is: private _jumpStep:number = 0.0;

“.” is not the end of a code line. it’s short for “0.0”;

the better way to end a ts line is using ‘;’ or just letting it do nothing.

Yeah, we don’t actually have to terminate statements… some of the engineers on my team do it for readability… but, if you do, use “;” or don’t put anything at all. The “.” after a number is to either specify a floating value or to signify that it is “.0” … nothing follows. Your periods that didn’t throw an error were immediately after an integer… so the computer read it as “.0” Ex. if you had let mynumber = 1. the computer would read it as 1.0… but when you put the decimal point after the parenthesis… you created a syntax error. It didn’t know what to do with your decimal point because it’s not expecting it.

If you want to terminate your statement (the equivalent of ending a sentence with a period in the english language) you can, but you should use “;” instead of a decimal/period. Again, you don’t have to use anything… you absolutely can go to the next line and start your next line of code.

1 Like

Thanks for your feedback. I’ve checked the code in the tutorial. I found several code lines mistype the ‘;’ by ‘.’;

All of them are corrected, go and check the code again.

1 Like