God, I really thought this would work but maybe it's cause my code is a basic mess, i'm trying simply everything i see on internet... in my head the code works, but reality not so much
In the boss scene, I'm trying to make the bullet locate the player, I tried figuring out what u sugested ("calculate the distance"), but if my player is constantly moving, and so is the Boss, how do I calculate this? LoL
This is my mess, I don't know if the problem is I'm using a Static Body or not, or everthing else
(it keeps appearing the null instance error for global_position)
`extends StaticBody2D
var speed = 100
onready var player = preload("res://Player.tscn").instance()
func ready():
setprocess(true)
func _process(delta):
shoot()
func shoot():
getparent().getnode(".").addchild(player)
var shot = preload("res://Beam.tscn").instance()
var direction = (lookat(player.globalposition) - $muzle.globalposition).normalized()
shot.globalposition = $muzle.globalposition
shot.dir = Vector2(cos(rotation), sin(rotation)).normalized()
getparent().getnode(".").add_child(shot)`