- Edited
- Place ~~~ before and after the code you posted so that it can be read.
- Post the link to the tutorial. There are many versions.
- Post the exact Godot version that you're using.
Hi, I managed to find the issue by downloading the completed project of this tutorial
The issue lies in func _on_mob_timer_timeout():
there is no mob_timer node in my project, i have to follow the name.
it looks like the tutorial did not mention this
Edit: I recreated the project again and mobs did not appear
DaveTheCoder
thanks for the advice and replying, I did not see your message when I found the solution
it turns out I forgot to link the tutorial in OP
I am using godot 4.2
Thanks for fixing the code display.
For reference, here's the tutorial link with the Godot version specified:
https://docs.godotengine.org/en/4.2/getting_started/first_2d_game/05.the_main_game_scene.html
Using the "stable" link has the problem that it changes when a new stable version of Godot is released.
By exact Godot version I meant this: v4.2.1.stable. You can copy that to the clipboard by clicking on the version at the bottom right of the editor window, or in the Help / About Godot dialog. But that detail probably isn't relevant in this case.
game_enjoyer there is no mob_timer node in my project,
The tutorial includes this:
Now, add the following nodes as children of Main, and name them as shown (values are in seconds):
Timer (named MobTimer) - to control how often mobs spawn
Is that what you meant?
DaveTheCoder
hi, sorry to bother you but I am experiencing the same error again.
I edited the OP script, and ran the scene but enemies mobs do not appear
Edit: Here is my exported project, if anyone can please help me on this issue, I am truly grateful.
Once again, the issue is no enemies spawn when I start the game
[https://github.com/claritybear/TUTORIAL-PROJECT](https://)
Can you upload the project folder?
There is a ^
in var mob_spawn_location = get_node(^"MobPath/MobSpawnLocation")
The project would be helpful, if the above wasn't the issue.
Is the github link enough?
I can upload the folder but I won't be able to upload anything else for now
trizZzle
I will try removing the ^ when I'm able to, thanks
game_enjoyer Is the github link enough?
Yes.
You didn't connect the timeout signals for the three Timers. They need to be connected to the corresponding functions in the main.gd script.
As the tutorial says:
Now connect the timeout() signal of each of the Timer nodes (StartTimer, ScoreTimer, and MobTimer) to the main script. StartTimer will start the other two timers. ScoreTimer will increment the score by 1.
After I connected the signals, the enemies appear.
trizZzle There is a ^ in var mob_spawn_location = get_node(^"MobPath/MobSpawnLocation")
Actually, that's valid. I had to look it up in the documentation. The ^ makes the string a NodePath, which is the correct type of the argument of get_node(). It's not required, since NodePath has a constructor that converts a String to a NodePath.
Thanks so much, I was on the fence for switching to Unity.
Some of my favorite games are created in Unity.
I'll continue godot for now and see how it goes
DaveTheCoder trizZzle There is a ^ in var mob_spawn_location = get_node(^"MobPath/MobSpawnLocation")
Actually, that's valid. I had to look it up in the documentation. The ^ makes the string a NodePath, which is the correct type of the argument of get_node(). It's not required, since NodePath has a constructor that converts a String to a NodePath.
Looked like a typo to me as it wasn't in the linked tutorial.
my god, another issue I have is now when character dies, MobTimer does not stop and keep spawning mobs?
Edit: Nevermind, it seems my StartTimer has the autostart property on, after turning it off mobs stop spawning after character dies
I ran into another issue..., I am really so frustrated
On this site: https://docs.godotengine.org/en/stable/getting_started/first_2d_game/06.heads_up_display.html
"In the Node tab, connect the HUD's start_game signal to the new_game() function of the Main node by clicking the "Pick" button in the "Connect a Signal" window and selecting the new_game()"
I am unable to connect to new_game, there is no option
I updated my github as well
EDIT: I NOTICED another solution which is to type new_game in the Filter Methods box, this will create a new_game function
Does this work as well?
The problem is that the script HUD.gd is attached to both the Main node and the HUD node. That's why the functions in main.gd are not showing up in the connect dialog.
Right-click on the Main node, and attach the script main.gd.
I am finally done with this tutorial, I plan on testing myself and adding additional features to this game, but it won't be on this thread.
Thank you very much and everyone else who helped on this thread.
I just have 1 issue, I was tinkering with the source code for this game on github and ran into an error, its up to you if you want to help with this, i did not touch the mob script or tscn at all
The error is "Script inherits from native type Rigidbody2d so it cant be assigned to an object of type pathfollow2d
here is the folder for the project: https://github.com/claritybear/Original-dodge-the-creps
Script inherits from native type Rigidbody2d so it cant be assigned to an object of type pathfollow2d
This is literally the error. The script is attached to the wrong node type; i.e. the extends
part of the script needs to match the node type.
Script inherits from native type 'RigidBody2D', so it can't be assigned to an object of type: 'PathFollow2D'
The script mob.gd is attached to the node Main/MobPath/MobSpawnLocation in the scene main.tscn. Detach it.