0 votes

So i'm trying to make a top-down 2d shooter in Godot 3.5, and for the most part, it works. The bullets fire fine when i'm not moving. However there's this thing where when i move too fast, the bullets start to shoot out at the wrong direction.
Here's what the code for the fire() function looks like:

Godot version 3.5.stable
in Engine by (23 points)

It might be because your player has moved by the time addchild() is called. Have you tried calling addchild immediately instead of deferred?

So just remove _deferred?

Not quite: "get_tree().get_root().add_child(bullet_instance)".

If that doesn't work, try setting the bullets position to the correct position in its _onready().

did you set it as toplevel so it doesn't follow any parents?

Figured it out, and i'll leave it here for anyone else who might have the same problem; i was instancing the bullets from inside the player body, and it was colliding with itself, causing the bullets to ricochet off the character. I solved it by just putting an Area2D in front of the character.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.