When I fire in the game, two projectiles come out. Why?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CarlitosCUeba

I’m making a TopDown game but when I put the Player scene in the World scene, two shots come out, one at the player and the other at point 0 of the scene. The world is a node.

Without seeing any code, my only assumption is that your if condition only checks to see whether the input event was a mouse button press. When you click the mouse you get two events: one where pressed = true (mouse down) and one where pressed = false (mouse up).

Post the code and I can give you a more definitive answer.

timothybrentwood | 2021-06-05 21:50

Also, you can try using global position.

Asthmar | 2021-06-07 20:38

if(Input && ContadorTiro == 0)
    {
        var Rotation = (GetGlobalMousePosition()- GlobalPosition).Angle();

        Bullet.Rotation = Rotation;
        Bullet.Position = Position;
        GetParent().AddChild(Bullet);

        ContadorTiro = TempoDeSaida;
    }
    else if(ContadorTiro > 0)
    {
        ContadorTiro -= 1;
    }

*Bullet is an instantiation of the scene
My problem is that when I use Position and GlobalPosition in a scene where I instantiate the Player, two Vector2 values ​​are returned. Carrying the projectile shoots from the two positions

CarlitosCUeba | 2021-06-09 01:33

My problem is that when I use Position and GlobalPosition in a scene where I instantiate the Player, two Vector2 values ​​are returned. Carrying the projectile shoots from the two positions. That is, it still doesn’t work

CarlitosCUeba | 2021-06-09 01:35