Godot Version
godot 4.2.2
Question
Was following a tutorial for adding new bullets, in my case. The ‘add_child’ is not liking any variation I’ve done (such as instancing the scene, then using $Bullets.add_child(b)). Thanks in advance.
extends CharacterBody2D
@export var muzzle_velocity = 350
@export var gravity = 250
var Bullets = preload(“res://bullet.tscn”)
func _process(_delta):
if Input.is_action_pressed(“shoot”):
shoot()
func shoot():
var b = Bullets.instantiate()
Bullets.add_child(b)
b.transform = $Player / Position2D.global_transform
b.velocity = b.transform.x * muzzle_velocity
b.gravity = gravity