Skip to content

Commit

Permalink
pass position and rotation to SpawnAgent in config
Browse files Browse the repository at this point in the history
(cherry picked from commit eec4c58)
  • Loading branch information
EricBoiseLGSVL committed Aug 3, 2021
1 parent f08dd42 commit 250c373
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions Assets/Scripts/Api/Commands/AddAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public async void Execute(JSONNode args)

VehicleDetailData vehicleData = await ConnectionManager.API.GetByIdOrName<VehicleDetailData>(name);
var config = new AgentConfig(vehicleData.ToVehicleData());
config.Position = position;
config.Rotation = Quaternion.Euler(rotation);

if (ApiManager.Instance.CachedVehicles.ContainsKey(vehicleData.Name))
{
Expand Down Expand Up @@ -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);
}
Expand All @@ -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)
{
Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/Managers/AgentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 250c373

Please sign in to comment.