|
|
|
|
Reply From: |
Jowan-Spooner |
Sorry but KinematicBody2d does not have a motion property.
Maybe this will help:
You can think of the nodes as predefined scripts (it’s more complicated but that’s a good way to understand them). These “scripts” already have some variables that are defined, in your example the rotation variable. Many of them can be edited in the inspector. They are called properties.
On the other hand each node can have another script made by you, that can contain variables that you created yourself. The scripts can also edit/set the value of the nodes properties.
Please note also that Vector2() isn’t setting a type, but instead it returns a value (an empty Vector). You do not have to set the type of any variable, though it is possible since godot3.1. Vector2 is a datatype that contains a x and a y. Of course the code will make problems if you change the name of a property, because the “script” that defines the nodes basic behavior tries to find it. Changing the type of a property leads to trouble to, because godot is expecting a certain type.
Did that help you? I hope so. Feel free to ask more questions if not.
Hmmm…it’s more clear now but i have two more questions.
When i press the F4 button and i type “KinematicBody2D”, in the properties i can see a word “motion”.So, what is it?
And second:Why, when i changed the “motion” word in “move” word in my Script, then the code had not any problem?
Nick888 | 2019-05-11 11:22
I am sorry, I am still using godot3.0 most of the time so I didn’t find it in the first place. This motion isn’t a property of the object. If you look into the inspector you can see that it is the name of one section there, holding the property sync_to_physics.
Secondly: From what you said I believe that you create the variable motion inside your script, which means it is somehow a local variable. So changing all occurrences of the name to something else will not affect any other script, thus let everything work fine. But it would become a problem if you would change the name in one place only.
Does that sound logical. Good luck!
Jowan-Spooner | 2019-05-11 12:34
Now its apsolutely clear. I mean about the “holding the property sync_to_physics”.Now makes sense and the issue with the variable name "motion"You are right!
Thank you very much!
Nick888 | 2019-05-11 12:41
You are welcome, glad I was able to help.
Jowan-Spooner | 2019-05-11 12:57