Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | austinthepierce |
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.is_action_just_pressed(“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?
How about, when the bullet is spawned, assign the position of the muzzle (i.e. the global position of the muzzle) to the position of the bullet.
Ertain | 2021-09-30 06:21