/// <summary> /// Instantiates bots using the config file param values. It defaults some uninitialized values using the player's coords /// </summary> /// <param name="config">The config file to be used</param> public IEnumerator InstantiateBotsAtCoords(CoordsInstantiationConfig config) { if (config.xCoord == EnvironmentSettings.UNINITIALIZED_FLOAT) { Log($"X Coordinate value wasn't provided... using player's current scene base X coordinate."); config.xCoord = Mathf.Floor(DCLCharacterController.i.characterPosition.worldPosition.x / ParcelSettings.PARCEL_SIZE); } if (config.yCoord == EnvironmentSettings.UNINITIALIZED_FLOAT) { Log($"Y Coordinate value wasn't provided... using player's current scene base Y coordinate."); config.yCoord = Mathf.Floor(DCLCharacterController.i.characterPosition.worldPosition.z / ParcelSettings.PARCEL_SIZE); } var worldPosConfig = new WorldPosInstantiationConfig() { amount = config.amount, xPos = config.xCoord * ParcelSettings.PARCEL_SIZE, yPos = DCLCharacterController.i.characterPosition.unityPosition.y - DCLCharacterController.i.characterController.height / 2, zPos = config.yCoord * ParcelSettings.PARCEL_SIZE, areaWidth = config.areaWidth, areaDepth = config.areaDepth }; Log($"Instantiating {config.amount} randomized avatars inside a {config.areaWidth}x{config.areaDepth} area positioned at ({config.xCoord}, {config.yCoord}) coords..."); yield return(InstantiateBotsAtWorldPos(worldPosConfig)); }
public void InstantiateBotsAtCoords(string configJson) { var config = new DCL.Bots.CoordsInstantiationConfig(); JsonUtility.FromJsonOverwrite(configJson, config); CoroutineStarter.Start(botsController.InstantiateBotsAtCoords(config)); }