from unity import *

import ComponentUtil
import SteeringControl
import Steering

class GetDistance(SteeringControl):
	def __init__(self, distance):
		self.controller = False
		self.steerInit("Get Distance", 500)
		self.distance = distance

	def init(self):
		self.steering = ComponentUtil.findInLineage[Steering](self.gameObject)
		self.destination = self.gameObject.transform.position + (Random.onUnitSphere * self.distance)

	def step(self):
		self.steering.steerTowardsPoint(self.destination)

		if Vector3.Distance(self.gameObject.transform.position, self.destination) < 15:
			self.controller.pop(self)
