Setting variables to NPCs and displaying them in a widget help


Tweaked it here similar to your example

1 Like

Perhaps something along the lines of:

  • the manager actor generates names:

image

  • the game mode creates the name generator:

  • the farmer gets a new name:

  • the widget can be updated:

  • the player clicks a farmer:


This can be made better but we’d need to know the scope. I am assuming you’ll be clicking on things other than farmers, too, surely. But it can be factored in later on.

2 Likes

Thank you! I am making these changes now, will update soon.

As for scope its a colony sim kind of personal game project, so there will be a fair bit of clicking involved

1 Like

its a colony sim

I’ll probably start writing a manager for spawning colonists then, it could generate names and then spawn them. Something like:

This way there’s no need to faff around inside the colonist BP. Their data is already set when they spawn. Consider it and also consider looking into structs - these will allow you to push a bunch of data in one go rather than fiddle with 15 separate variables.

Yes I would prefer to do it that way, seems more efficient. Would the manager for spawning colonists be a function inside the game mode or its own actor?

Up to you. It’s about the scope - you know what the plan is. Things often become an order of magnitude more complex than one anticipates. A Game Mode that has a bunch of Manager Actors, each responsible for a different task is not a bad idea at all.

Blueprints become a tangled mess sooner rather than later.

That’s for sure!
Ah so a manager actor is just a separate empty actor

I think I have everything set up now, going to do a quick test, all compiles come back clean

Yeah, not for long, though.

1 Like

not for long indeed!

Did a quick test buuuut no widget was displayed hmmm, no error in the log either though.

Checked I set the visibility correctly in the Player BP

You’re supposed click on a farmer actor, right? This is the name generator.

1 Like

Thats the one! haha fixed that and it kind of works, its kind of tricky to hit the actors buuuuut using this overlap check gets the hit everytime

And it does now indeed work

Thank you!!

1 Like

So place a box/spere volume set as invisible? and use that as a hit trace?

No I got to figure out how to spawn colonists in a separate actor out of game mode, but also set a starting amount of colonists :thinking:

Currently using the Cropout Sample project as a way to spawn my colonists which is set up like this

You may give them a sphere / box volume that reacts to a specific trace channel. This would allow you the hit a dude(tte) no matter how well they hide in the bushes.

Note Ignore :point_up: and collision settings :point_down: of this box:

Now you can trace for one thing only and have a much bigger target to mouse over:

Sometimes you may want to click on buildings only, or enemies only and the colonist can get in the way of clicks.

No I got to figure out how to spawn colonists in a separate actor out of game mode, but also set a starting amount of colonists

The spawner manager should know how many to spawn. How do you know how many you want?

Cropout Sample

Aware of it but do not know the internal shenanigans. Can’t relate.

Thanks going to set up this sphere box trace now,

And for the spawn manager I have 3 difficulty modes set up that set a variable for the amount of villagers to spawn, but when I tried using for for loop and plug in one of those variable into the last index it only every spawned one

Cropout is quite interesting though the enhanced input mapping is confusing

Yeah, but that’s not a Cropout issue. It’s a relatively new system that takes a while to get used to. Better than what we had, for sure.

I have 3 difficulty modes set up that set a variable for the amount of villagers to spawn

Like this maybe:

Very true, quite a struggle to get used to when 2 buttons in one IA but you want one button to rotate one way and the other button to rotate the other way haha

So I set up the box collision for hit results and works a treat, is this set up correctly

Set up the new spawning


The current difficulty variable is set form the main menu,

Instead of the spawn actor node, wouldn’t the spawn Villager function work as well? This is what that looks like

I would be preferable, ofc.

Actually I have a bug where when I start a new game, nothing spawns at all :thinking:

Had to migrate to a new project for reasons, set up a spawn point and can spawn my colonists, but cant get the name generations working as I dont see where the generate details text variables can plug into on the spawn actor

also this is the even graph where the function is being called


this piece of code that was suggested for Everynone used to work, but when I try it now, it doesnt work hmmmm

Any ideas what might be missing?

1 Like