Based on the ArcGIS Maps SDK for Unreal Engine v2.2.0 plugin running on Unreal Engine 5.5.
I need to implement a procedural random foliage spawning feature, with the technical workflow broken down into the following steps:
1.Utilize the raycast function provided by the SDK to retrieve ground position data at the mouse click point.
2.Take the clicked ground coordinate as the center point, then generate multiple randomized offset coordinates; the total spawn count is adjustable via exposed parameters.
3.Spawn clones of the designated blueprint asset, each equipped with a ArcGISlocation component.
4.Assign the procedurally generated coordinate values to the ArcGISlocation component of each cloned actor, and set Surface Placement Mode to On the Ground.
5.Serialize and save the location data of all spawned foliage clones to a local JSON file.
6.On subsequent application launches, deserialize the JSON data and respawn the corresponding foliage assets.
Issue Description
During real-time runtime spawning, the cloned foliage actors fail to consistently snap to the ground — some sit on the terrain surface while others spawn underground. I suspect there is an issue with the calculation logic of the On the Ground property described in Step 4, and its ground alignment effect does not take immediate effect.Generate Grass
This is because after closing and restarting the program, when initializing foliage clones by loading the saved JSON coordinates, the ground snapping function of the location component works properly as expected.
Initialize Grass
I confirm every actor has an ArcGISLocation component.
Grass Blueprint
What is the root cause of this inconsistency?
This is a interesting usecase and approach. My initial thought would be that the inconsistency is due to different LoDs being loaded. The tiles are streamed with different levels of detail depending on the camera position, size on screen, etc. So as the camera moves, the tiles will update with better or worse LoD. So even within one session the surface altitude is not constant.
Just to clarify, do you attach the location component to the foliage when spawning them from JSON positions or only when spawning them in the first run? Generally the location component will react to the changes of the terrain and move up and down in real time (the mesh needs to be movable). If that's not happening, something may not be initialed properly in the location component. Also, is the horizontal placement consistent across sessions?