Jesusemora im using the regular gdscript language
[GODOT 4.1] .gd file bar not appearing in area2d's inspector tab
SuperGibaLogan Post the screenshot of your entire editor with the node selected. Also post the attached script code.
Dude it's telling you where the error is. You could've shown us this before.
func
and _process
need a space.
Jesusemora func and _process need a space.
dont we all?
- Edited
Jesusemora The custom class properties declared in the script are not showing in the inspector because the engine was unable to compile the script due to a syntax error. The editor is telling you about the error by printing a red error message and highlighting the line(s) of code that contain the error.
SuperGibaLogan i wrote the code exactly how the tutorial did though
You did not though.
- Edited
xyz SuperGibaLogan i wrote the code exactly how the tutorial did though
You did not though.
lets see
yup
Jesusemora oh
btw sorry that i didnt show it before
Jesusemora i putted a space between func
and _process
- Edited
SuperGibaLogan May not be the only error you made when typing the code. Any more error messages displayed by the engine? You should fix them all. Otherwise the script cannot compile and its properties won't be displayed in the inspector.
xyz there was a couple other errors i noticed, im wondering if they are actually errors or the engine read them wrong and thought they were wrong (i wrote these lines of code exactly how the tutorial shows how)
- Edited
SuperGibaLogan (i wrote these lines of code exactly how the tutorial shows how)
Again, you didn't. You made errors when re-typing the tutorial code.
You need to learn the basics of GDScript syntax so you can understand what you're actually typing. It's pointless to mindlessly copy the code without understanding it, and as you can see, it's very easy to unwittingly produce a bunch of typos. I'd suggest to do a more basic tutorial than this one. Preferably the introductory 2d tutorial in the engine docs. Go slow and focus on what is being shown. Details matter a lot when coding. One mistyped character can break your entire script.
Luckily the engine tells you about it. An error message will always be shown when there is an error in a script. Aim to understand what a particular error message means. It's your hint about what you did wrong.
In the code you posted above, you have at least one syntax error; missing colon after typed function argument next_position
xyz i see, but the tutorial im using is the only tutorial i could find that does all the gameplay mechanics perfectly
also i typed the code, not copy and paste it (my code isnt fininshed yet just so you know)
xyz ill look forward into the engine docs
SuperGibaLogan also i did some edits to the code, thats why it looks a little different
SuperGibaLogan im currently thinking of ways on how to fix the errors, im also looking at the errors listed in the syntax to think of ways to fix the errors, also, would it be ok if i could show the entire code and also show the errors listed?
- Edited
SuperGibaLogan would it be ok if i could show the entire code and also show the errors listed?
Of course. You should have done that right away.
At this point you shouldn't really worry about gameplay mechanics. Learn the programming basics first following the simplest introductory tutorials.
xyz alright then
heres the code:
extends Area2D
var current_scatter_index = 0
@export var speed = 75
@export var movement_targets = Resource
@export var tile_map = TileMap
@export var navigation_area_2d = $NavigationAgent2D
func _ready():
navigation_area_2d.path_desired_distance = 4.0
navigation_area_2d.target_desired_distance = 4.0
navigation_area_2d.target_reached.connect(on_position_reached)
call_deferred("setup")
func _process(delta):
move_ghost(navigation_area_2d.get_next_path_position(), delta)
func move_ghost(next_position Vector2 delta float)
var current_ghost_position = global_position
var new_velocity = (next_position - current_ghost_position).normalized()
func setup():
navigation_area_2d.set_navigation_map(tile_map.get_navigation_map(0))
NavigationServer2D.agent_set_map(navigation_area_2d.get_rid(), tile_map.get_navigation_map(0))
func scatter():
navigation_area_2d.target_position = movement_targets.scatter_targets[current_scatter_index].position
func on_position_reached():
if current_scatter_index < 3:
current_scatter_index += 1
else:
current_scatter_index = 0
and these are the errors listed (i figured out most of them but i tried to remove the comma and colon from line 20 but it still shows the error):
Line 20:Expected closing ")" after function parameters.
Line 20:Expected ":" after function declaration.
Line 20:Expected end of statement after expression, found "Identifier" instead.
SuperGibaLogan sigh
you are using SPACES, do you not understand the difference?
gdscript uses TABS for defining pretty much everything, indentation and syntax are very much important, this isn't C# where you can skip the brackets.