Currently, when spawning an actor with collision and simulate physics on, at a location with other objects with collision and simulate physics on, it causes the objects to bounce around since we are trying to spawn an object inside another object.
The “Try to adjust spawn location” also doesn’t always seem to work and lack certain flexibility (e.g. it sometimes chooses to spawn the object underground which is not what I want).
Currently I’m considering doing a search to find the closest non-colliding location to place the object though I have no idea how to accomplish that right now…
Does anyone have any suggestions on how to elegantly spawn an actor with collision and simulate physics on?
A blueprint method is preferred but I’ll also accept C++ suggestions.
Old question, but for the sake of Googlers: Have you thought of using the Environment Query System?
You could check some of the the nearest points with like 100 distances from each other, filter the points by a successful sphere trace, and order them by distance. At the end you’ll get one location, which is the most optimal point to place your object.
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
Easiest way would be to surround Object A with a Volume, and Object B with another Volume. These volumes are a bit larger than their respective objects. With the volume selected in blueprint, use the event on object begin overlap. Check for the other overlapping volume. Should be able to calculate a desired location from there. Hope this helps.