DISCLAIMER: im a total beginner
I figured out how to spawn bullets when I press right mouse
"muzzel"
const bulletPath = preload("res://bullet.tscn")
`func process(delta):'
'if Input.isactionjustpressed("primary fire"):
'shoot()
func shoot():
var bullet = bulletPath.instance()
get_parent().add_child(bullet)
And i figured out how to make them in the direction of the raycast.
"bullet"
func _process(delta):
translate(Vector3(0,0,1) * SPEED * delta)
However, when I press right trigger, the bullet spawns 2 meters behind the camera. Like, when I look down, it spawns above me. How do I code it so that it spawns exactly where the muzzel is?