Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to Spawn Actor Function Attributes Map #7661

Closed
MTeuberItemis opened this issue May 16, 2024 · 3 comments
Closed

Add to Spawn Actor Function Attributes Map #7661

MTeuberItemis opened this issue May 16, 2024 · 3 comments
Assignees
Labels
art Requires changes/additions to art content

Comments

@MTeuberItemis
Copy link

MTeuberItemis commented May 16, 2024

Im currently trying to add an additional boolean to a walker, so I can set it from python scripts. It should work similar to e.g. "is_invincible". In python it looks like following: walker_bp.set_attribute('is_invincible', 'false')

I tried to figure out, how I can add such a boolean and managed to work my way to the "Spawn Actor" function in the WalkerFactory, where the following node seems to make it work:
image

The input, "Attributes", is unfortunately a mystery to me and I can't figure out, where I can add another ID to that Map.
image

When I print out the map, the following attributes are included:

LogBlueprintUserMessages: [WalkerFactory_C_0] role_name
LogBlueprintUserMessages: [WalkerFactory_C_0] gender
LogBlueprintUserMessages: [WalkerFactory_C_0] speed
LogBlueprintUserMessages: [WalkerFactory_C_0] is_invincible
LogBlueprintUserMessages: [WalkerFactory_C_0] generation
LogBlueprintUserMessages: [WalkerFactory_C_0] age

Can someone help me here?

This is carla 0.9.13

@Madecu
Copy link
Contributor

Madecu commented May 17, 2024

Hi @MTeuberItemis,
Those attributes are declared in a C++ class.
First, you need to add your new variable to the Pedestrians structure.
image

Then, define it in ActorBlueprintsFunctionLibrary
image

@Madecu Madecu self-assigned this May 17, 2024
@Madecu Madecu added the art Requires changes/additions to art content label May 17, 2024
@MTeuberItemis
Copy link
Author

Thank you for that input, that already helps a lot.
But I still get some errors that I dont really understand.

There are two cases I tested with different outcomes: [everything in carla 0.9.13]

CASE 1:

I added following code:
PedestriansParameters.h: line 59 (bottom of the code)

...
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool on_wheelchair = false;
};

ActorBlueprintFunctionLibrary.cpp: line 1124:

Definition.Attributes.Emplace(FActorAttribute{
TEXT("on_wheelchair"),
EActorAttributeType::Bool,
GetWheelchair(Parameters.on_wheelchair)});

this resulted in a build error, when I tried to launch my locally built carla:
it stopped at module 5/8:

make: *** [CarlaUE4Editor] Fehler 6

CASE 2

inspired by: how "is_invincible" was added, i made no changes to original pedestrianparameters.h
and added following to
ActorBlueprintFunctionLibrary.cpp: line 1144:

FActorVariation OnWheelchair;
OnWheelchair.Id = TEXT("on_wheelchair");
OnWheelchair.Type = EActorAttributeType::Bool;
OnWheelchair.RecommendedValues = { TEXT("false") };
OnWheelchair.bRestrictToRecommended = false;

with this it was possible to build, but unfortunately when I tried to spawn walkers, it gave me following error:

Unknown error while trying to spawn actor

Interestingly, "on_wheelchair" also got added to the properties mentioned in my original question:

LogBlueprintUserMessages: [WalkerFactory_C_0] on_wheelchair
LogBlueprintUserMessages: [WalkerFactory_C_0] role_name
LogBlueprintUserMessages: [WalkerFactory_C_0] gender
LogBlueprintUserMessages: [WalkerFactory_C_0] speed
LogBlueprintUserMessages: [WalkerFactory_C_0] is_invincible
LogBlueprintUserMessages: [WalkerFactory_C_0] generation
LogBlueprintUserMessages: [WalkerFactory_C_0] age

@MTeuberItemis
Copy link
Author

it was actually a problem in another part of the walkerFactory. the second approach works just fine. thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
art Requires changes/additions to art content
Projects
None yet
Development

No branches or pull requests

2 participants