So I have a raycast node and for some reason objects are printed, but the thing is I can only call once to print the collision object's name. so anyway when my bullet collides it deletes itself and prints 'Hit'. I need to get the deletion call from the bullet to be able to update in my root node. The bullet itself does not show up.
this is the relevant code:
func _input(event):
if event is InputEventMouseMotion:
$Sprite.global_transform.origin = event.position
mmousex = event.position.x
mmousey = event.position.y
$Player/Camera/RayCast.cast_to = Vector3(mmousex, mmousey, -1000000)
func _unhandled_input(event):
if event is InputEventKey:
if event.pressed:
if event.scancode == KEY_G:
if bulcnt < 1:
var bulinst = bulref.instance()
bulinst.name = "Bullet" + str(bulcnt)
bulinst.global_transform.origin = Vector3(0, 0, 0)
var movvec = -($Player/Camera/RayCast.get_collision_point() - $Player.global_transform.origin).normalized()
var targ = $Player/Camera/RayCast.get_collider()
print(targ)
buldir.append(movvec)
$Player.add_child(bulinst)
bulcnt += 1
func _physics_process(delta):
if bulcnt > 0:
for i in range(bulcnt):
var bulnod = $Player.get_node("Bullet" + str(i))
var movvec = buldir[i] * delta
if bulcnt > 0:
if bulnod:
bulnod.global_transform.origin += movvec