/// <summary> /// Gets the spawn position. /// </summary> /// <returns>The spawn position.</returns> /// <param name="_base_offset">Base offset.</param> public Vector3 GetSpawnPosition(float _base_offset = 0) { Vector3 _position = Vector3.zero; GameObject _object = GetBestSpawnPointGameObject(); if (_object != null) { if (UseRandomRect) { _position = PositionTools.GetRandomRectPosition(_object.transform.position, RandomRect, true); } else if (SpawningRangeMax > 0) { _position = PositionTools.GetRandomCirclePosition(_object.transform.position, SpawningRangeMin, SpawningRangeMax); } else { _position = _object.transform.position; } _position.y = PositionTools.GetGroundLevel(_position, CreatureRegister.GroundCheck, CreatureRegister.GroundLayerMask, 0.5f, LevelDifference, _base_offset); _position.y += _base_offset + LevelOffset; } return(_position); }
/// <summary> /// Gets the ground level. /// </summary> /// <returns>The ground level.</returns> /// <param name="_position">Position.</param> /// <param name="_offset">Offset.</param> public static float GetGroundLevel(Vector3 _position, float _offset = 0) { if (ICEWorldRegister.Instance != null && ICEWorldRegister.Instance.Options.GroundCheck == GroundCheckType.RAYCAST) { return(PositionTools.GetGroundLevel(_position, ICEWorldRegister.Instance.Options.GroundCheck, ICEWorldRegister.Instance.Options.GroundLayerMask, 0.5f, 1000, _offset)); } else { return(PositionTools.GetGroundLevel(_position, 0.5f, 1000, _offset)); } }