I am having trouble with path2Ds. So the enemies spawn at intervals as per the "your first game". However, what I want is for them to spawn and move towards/go to a stationary character or a set of coordinates from wherever they spawn.
I have tried a bunch of stuff and can't get it to work. Any ideas?
Code would be appreciated.
(If it makes any difference the player will use a centre of gravity to attract the enemies of their path - would I need to define a new path so that they don't continue to go back to the hub immediately, but after a certain time?)
$Path2D/PathFollow2D.offset = randi()
var mob = Enemy.instance()
var facing = $Hub.position
var direction = facing.rotation
mob.position = $Path2D/PathFollow2D.position
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = mob.linear_velocity.rotated(direction)