0 votes

Hello everyone. I am a begginer in Godot and GDScript, so my question might have an obvious answer.

I am making a turret game but when the player shoots, the bullets follow the mouse.

Here is the code for bullet movement and spawning:

if Input.is_action_pressed("shoot_bullet") and can_fire:
    var bullet = bullet_scene.instance();

    bullet.position = $point.position;


    bullet.apply_impulse(Vector2(), Vector2(bullet_speed, 0).rotated(deg2rad(rotation_degrees - 90)));


    add_child(bullet);
    print("Shooted a bullet");

    can_fire = false;
    $Timer.start(fire_rate); yield($Timer, "timeout") 
    can_fire = true;

What is that I have implemented wrong? How can I stop this? Thanks in advance

Godot version v3.5.1
in Engine by (12 points)

I don't see any input from the mouse in your code.

It is the "shoot_bullet" action. I have registered it as left click

Does bullet have a script?

None else that affects movement

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.