hello guys, I am making just a shooter game and I have managed to make an enemy that moves and shoots bullets in one direction using this :
export var rocket = preload("res://MainScenes/enemyRocket.tscn")
func fire():
var roc = rocket.instance()
get_tree().get_root().add_child(roc)
roc.global_position = global_position
I call this fire function in the func _process
and I have some other statements that manage the timings of fire rate etc. What I want to know is that how can I make the enemy fire at my ship instead of just one place. Can I add something in the above code to do that ?
I managed to make the bullets point in my direction using these :
var dir = (get_player().global_position - global_position).normalized()
roc.global_rotation = dir.angle() + PI / 2.0
But this just makes the bullets point towards me. What can I do to actialy make them come towards me ?