private void Spawn() { float angle = ((Mathf.PI * 2) * Random.value); float sin = Mathf.Sin(angle); float cos = Mathf.Cos(angle); // Pick a spawn position Vector3 spawnPosition = _root.position; spawnPosition.x += _radius * sin; spawnPosition.z += _radius * cos; GameObject go = _factory.CreateRandomPlane(spawnPosition, Quaternion.identity); go.transform.SetParent(_root); // Grab our directable component IDirectable iDirectable = go.GetComponent <IDirectable>(); // Set our primary travel position Vector3 primaryTravelPosition = _root.position; primaryTravelPosition.x += (_radius - _primaryTargetRadiusOffset) * sin; primaryTravelPosition.z += (_radius - _primaryTargetRadiusOffset) * cos; primaryTravelPosition.y += _primaryTargetHeightOffset; // Secondary Point angle = ((Mathf.PI * 2) * Random.value); Vector3 holdingPosition = _playerTransform.position; float hpRadius = Random.value * _holdingPositionRadius * _playerTransform.scale; holdingPosition.x += sin * hpRadius; holdingPosition.z += cos * hpRadius; Flightpath flightPath = new Flightpath(primaryTravelPosition); flightPath.drawPath = false; flightPath.AddPosition(holdingPosition); flightPath.Finialized(); iDirectable.AssignPath(flightPath, true); }
/// <summary> /// Takes a directable and forces it to land along /// the given path. /// </summary> /// <param name="iDirectable">The thing you want to land</param> public void LandDirectable(IDirectable iDirectable) { iDirectable.AssignPath(_landingPath, true); iDirectable.isInteractable = false; //_landingPath.drawPath = _landingPath.occupancy > 0; }