- Edited
Hello, forum, It's been a while since my last inquiry on this forum "IRL is quite busy this year", so I continue working on my game projects in my spare time. However, I've encountered a challenging hurdle related to the bullet mechanic. My intention is for the bullets to be fired from the front of a gun sprite, and I've attempted to align the bullet spawn script with the Bone2D of the hand on the sprite. Unfortunately, the outcome has not met my expectations.
I'm currently seeking guidance on how to make the bullets shoot toward the cursor in a manner similar to how I programmed the Bone2D hand to follow the cursor's position. Any advice or assistance would be greatly appreciated.
Also, this is how the script is written.
extends Bone2D
var shooting = true
var bullet = preload ("res://sprite/char/tm_a1/bullet_test.tscn")
func _physics_process(delta):
if Input.is_action_just_pressed("left_click"):
var bullet_instance = bullet.instance()
bullet_instance.rotation = rotation
bullet_instance.global_position = global_position
get_parent().add_child(bullet_instance)