Skip to content

Conversation

astralmaster
Copy link

@astralmaster astralmaster commented Jul 3, 2025

Description

Adds the ability to import custom blueprints created in UE4 to Carla's blueprint library, spawnable via Python API. Ported from Carla ue5-dev branch. In order to add your blueprint, create BlueprintParameters.json file in /CarlaUE4/Content/Carla/Config/ with following format:

{
  "Blueprints": [
    {
      "Name": "SomeBlueprintName",
      "Path": "/Game/Path/To/SomeBlueprintName"
    },
	{
      "Name": "SomeOtherBlueprintName",
      "Path": "/Game/Path/To/SomeOtherBlueprintName"
    }
  ]
}

If, for example, in your UE4 Content Browser you have a blueprint with path "Content -> Blueprints -> SomeBlueprintName", then you would modify the Path in BlueprintParameters.json as "Path": "/Game/Blueprints/SomeBlueprintName".

Then, from Python API:

world = client.get_world()
blueprint_library = world.get_blueprint_library()
blueprint_name = 'SomeBlueprintName'
bp = blueprint_library.find(blueprint_name)

Fixes #9018

Where has this been tested?

  • Platform(s): Windows 10 x64
  • Python version(s): 3.7
  • Unreal Engine version(s): UE 4.26.2

Possible Drawbacks

The code uses FindFunction() to determine whether PostProcessBlueprint has been used/implemented in UE4, should probably check if there is an easier, more robust way. This was needed to correctly determine whether the return value of PostProcessBlueprint should be taken into account when setting the SpawnResult.Status in BlueprintActorFactory.cpp's SpawnActor(). In the original BlueprintActorFactory.cpp from UE5, the code checks if PostProcessBlueprint returns true/false and sets the SpawnResult.Status accordingly, but if PostProcessBlueprint is not used in UE4, then the default return value is false and that wrongly (I assume) sets the SpawnResult.Status to EActorSpawnResultStatus::UnknownError.


This change is Reviewable

@astralmaster astralmaster requested a review from a team as a code owner July 3, 2025 20:00
Copy link

update-docs bot commented Jul 3, 2025

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.

@Blyron
Copy link
Contributor

Blyron commented Jul 3, 2025

Could you add a small .md on how have you done it to help people in the community?

@astralmaster
Copy link
Author

astralmaster commented Jul 4, 2025

Could you add a small .md on how have you done it to help people in the community?

As part of the CHANGELOG.md or separate .md? Where should that go?

@Blyron
Copy link
Contributor

Blyron commented Jul 4, 2025

Could you add a small .md on how have you done it to help people in the community?

As part of the CHANGELOG.md or separate .md? Where should that go?

You should add the title of the feature in the CHANGELOG.md and a tutorial of how to do it in
Docs/
in a file named something like tuto_add_blueprints_to_factory or something like that

@astralmaster
Copy link
Author

That should do it!

@Blyron
Copy link
Contributor

Blyron commented Jul 6, 2025

Yeah!
It makes it. We will review asap

@Blyron
Copy link
Contributor

Blyron commented Jul 15, 2025

The PR has compilinng issues;
Parsing headers for CarlaUE4Editor
Running UnrealHeaderTool "/__w/carla/carla/Unreal/CarlaUE4/CarlaUE4.uproject" "/__w/carla/carla/Unreal/CarlaUE4/Intermediate/Build/Linux/B4D820EA/CarlaUE4Editor/Development/CarlaUE4Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="/unreal-engine/Engine/Programs/UnrealBuildTool/Log_UHT.txt"
/__w/carla/carla/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorBlueprintFunctionLibrary.h(175) : Error: Unrecognized type 'FBlueprintParameters' - type must be a UCLASS, USTRUCT or UENUM
make[1]: *** [Makefile:1080: CarlaUE4Editor] Error 6
make[1]: Leaving directory '/__w/carla/carla/Unreal/CarlaUE4'
make: *** [Util/BuildTools/Linux.mk:88: CarlaUE4Editor] Error 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants