I want to spawn characters with different skeletal meshes.

Hi,
I also want to call an array but didn’t understand how to use it.
I am using this code to spawn NPCs, but I want them to spawn with different skeletal meshes.

I suppose you could have the spawner dictate this, but I’d have a function in the NPC that randomly selects the Skeletal Mesh that the spawner would then call for each spawned NPC.

If the NPC always should have a randomized skeletal mesh, then I’d consider having the NPC call the function directly in its BeginPlay function, then the spawner just has to worry about spawning.

Here is an example of what that function would look like.

That’s great! Now how should I call this function in my spawner BP?

How are you actually spawning your NPCs in the world? I don’t see you are using the spawn actor node:

If you are using it, you can simply drag off of the return value (is a reference to the NPC actor that was spawned) and call the random mesh function you created in that blueprint class.

1 Like

It worked Thank You so much bro.

1 Like

@Sklor
Hi, Is there any way by which I can add values to this array in BP?
I am making a spawner for spawning NP cars, and I want them to follow path points as they spawn in the world.

Yeah, you just have to have an instance of it already spawned in the world. So, this would need to be either: (1) you add one to your scene, then selecting it and adding to the array, or (2) doing it through scripting by spawning it, then referencing that variable from the reference and adding the splines to it.

@Sklor
I am using the same spawner for the NP cars.Also, is there any tutorial that you would recommend for making instances? I am a beginner to UE, so I am unable to figure out how I can make this spawner instance.