So when I export my game to web and upload it to itch.io, the collision for the coins doesn’t work. What it’s supposed to do is add a point to the player’s objective label, make a noise, and disappear from view. However, when I test it on itch.io it does none of those things. This was working fine in the code editor, though.
Here is my code for the “coin”:
extends Node2D
@onready var animator = $Area2D/AnimatedSprite2D
func _on_area_2d_body_entered(body: Node2D) -> void:
if body.name == "Dog": # Made it so that only the Dog touching the hotdog will increase the score
SoundBoard.chompSound.play()
Autoload.hotdogs_found += 1 # I found out that Autoload has to be capitilized to be worked
self.queue_free() # removes it from view
func _on_ready() -> void:
animator.play("default")
- Change your code to this:
func _on_area_2d_body_entered(body: Node2D) -> void:
print(body.name)
if body.name == "Dog": # Made it so that only the Dog touching the hotdog will increase the score
SoundBoard.chompSound.play()
Autoload.hotdogs_found += 1 # I found out that Autoload has to be capitilized to be worked
self.queue_free() # removes it from view
- Run it in the editor and note what gets printed out.
- Export a Web build again and turn debug on
- Upload it to itch.io (if you’re not using Butler, I recommend you take the time to learn as this step will then be 30 seconds instead of much longer.)
- Go to your game page.
- Press F12 (may have to hit it more than once) to make the debug console in your browser pop up.
- Start your game in the browser.
- Do the thing in the web game and see what gets printed out in the debug window.
Also, you might considering renaming Autoload to an actual descriptive name of what it does, as you may have reserved namespace issues using that name.