In the "Your first game" tutorial there is this code:
func _on_MobTimer_timeout():
# Choose a random location on Path2D.
$MobPath/MobSpawnLocation.offset = randi()
# Create a Mob instance and add it to the scene.
var mob = Mob.instance()
add_child(mob)
# Set the mob's direction perpendicular to the path direction.
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
# Set the mob's position to a random location.
mob.position = $MobPath/MobSpawnLocation.position
# Add some randomness to the direction.
direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction
# Set the velocity (speed & direction).
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = mob.linear_velocity.rotated(direction)
My questions concern rotation and position properties of MobSpawnLocation (a PathFollow2D node).
1) With this line:
# Set the mob's direction perpendicular to the path direction.
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
My question is, what direction is rotation initially, before I add anything to it?
2) Why does this code:
# Set the mob's position to a random location.
mob.position = $MobPath/MobSpawnLocation.position
Set the position to a random location? Is this randomness from the assignment of randi() to .offset?
Thank you