Hi,
I’m trying to spawn an actor in my scene through scripting in the editor. I can find a random location on the navmesh and spawn my actor here with this code, which will give me a valid point in a 1000 radius of the scene origin :
location = unreal.NavigationSystemV1.get_random_location_in_navigable_radius(world, unreal.Vector(), 1000)
my_actor = actor_subsys.spawn_actor_from_class(my_class, location, unreal.Rotator())
However when I do this in the editor in BP, I have a pin to specify a way to handle collision. I looked around in the unreal.py
file and the docs but this parameter is not available in the EditorActorSubsystem
related functions.
I found references of collision handling in the actor class itself:
-spawn_collision_handling_method`` (SpawnActorCollisionHandlingMethod): [Read-Write] Spawn Collision Handling Method:
Controls how to handle spawning this actor in a situation where it's colliding with something else. "Default" means AlwaysSpawn here.
so what I tried to do is modify my BP from the editor and set the property in the details pane to enable the proper collision handling method (DoNotSpawn rather than AlwaysSpawn). But when I spawn the actor from python and print the collision handling method it always returns SpawnActorCollisionHandlingMethod.ALWAYS_SPAWN: 1
and the setting I saved is ignored.
print(f'Spawned: {my_actor} with {my_actor.spawn_collision_handling_method}')
The problem here is although the actor is in a navigable zone, I still have collisions with other objects in the scene. I took the generated location 30-40cm down on the z axis before spawning it so it is partially underground. I expect the actor to not spawn in this situation. As a note, I’ve set the ground and my actor to blockall in the collisions channels.
How would I proceed to setup this ? I wish to have a script that when called will spawn an object from a class in my loaded level but in a situation where there won’t be any overlap between it and another object ( the ground for example).
Thank you !