I have a problem. I watched some tutorial videos to know how to create the code for shooting. But even if I tried some different codes, my character still can't shoot a bullet. Can anyone help me?
My character can actually move and rotate in any direction. It is a 2D board game. So I want it to shoot in the current direction it is facing at the moment.
I've written down this function for shooting:
var bullet = bullet_scene.instance()
bullet.set_linear_velocity(Vector2(sin(get_rot()) * bullet_speed, cos(get_rot()) * bullet_speed))
By default the shooting is set to false. I want to set it true by pressing a key, so I also have:
shooting = true
In _ready() function, I have "shooting()".
The bullet is a RigidBody2D without any script, just deactivated gravity and friction. The "firstweapon" is Position2D node. The bullet scene is loaded for the bulletscene var.
So what I am doing wrong?
Thanks in advance.