From 250c373a8d904f7185f35fdadf87051a0b967fdb Mon Sep 17 00:00:00 2001 From: "eric.boise" Date: Mon, 26 Jul 2021 18:39:08 -0700 Subject: [PATCH] pass position and rotation to SpawnAgent in config (cherry picked from commit eec4c586e7f84b863059cee4a2e1db5d43715a01) --- Assets/Scripts/Api/Commands/AddAgent.cs | 9 ++++----- Assets/Scripts/Managers/AgentManager.cs | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Api/Commands/AddAgent.cs b/Assets/Scripts/Api/Commands/AddAgent.cs index e9c149980..1012fe8dd 100644 --- a/Assets/Scripts/Api/Commands/AddAgent.cs +++ b/Assets/Scripts/Api/Commands/AddAgent.cs @@ -76,6 +76,8 @@ public async void Execute(JSONNode args) VehicleDetailData vehicleData = await ConnectionManager.API.GetByIdOrName(name); var config = new AgentConfig(vehicleData.ToVehicleData()); + config.Position = position; + config.Rotation = Quaternion.Euler(rotation); if (ApiManager.Instance.CachedVehicles.ContainsKey(vehicleData.Name)) { @@ -107,10 +109,9 @@ public async void Execute(JSONNode args) } } - if(config.BridgeData != null) + if (config.BridgeData != null) { - var pluginTask = DownloadManager.GetAsset(BundleConfig.BundleTypes.Bridge, config.BridgeData.AssetGuid, - config.BridgeData.Name); + var pluginTask = DownloadManager.GetAsset(BundleConfig.BundleTypes.Bridge, config.BridgeData.AssetGuid, config.BridgeData.Name); downloads.Add(pluginTask); assetDownloads.TryAdd(pluginTask, config.BridgeData.Type); } @@ -130,8 +131,6 @@ public async void Execute(JSONNode args) } agentGO = agents.SpawnAgent(config); - agentGO.transform.position = position; - agentGO.transform.rotation = Quaternion.Euler(rotation); if (agents.ActiveAgents.Count == 1) { diff --git a/Assets/Scripts/Managers/AgentManager.cs b/Assets/Scripts/Managers/AgentManager.cs index d4ca0bcc2..8e5d1bb5d 100644 --- a/Assets/Scripts/Managers/AgentManager.cs +++ b/Assets/Scripts/Managers/AgentManager.cs @@ -106,8 +106,7 @@ public GameObject SpawnAgent(AgentConfig config) } } - go.transform.position = config.Position; - go.transform.rotation = config.Rotation; + go.transform.SetPositionAndRotation(config.Position, config.Rotation); sensorsController.SetupSensors(config.Sensors); controller?.Init();