Hi there!
I have a “bullet” Blueprint. When the bullet hits the only enemy, (BP_NPC02), it fires off a series of events. This works just fine in BP_NPC02.
What I want to do is create copies of BP_NPC02, (whic would be named named BP_NPC03, BP_NPC04 etc), and have those copies work in identiical fashion to BP_NPC02.
However when I duplicate BP_NPC02, the new BP_NPC03 while working in all other ways, does not fire off the series of events. And here, in the bullet BP, I think, is why:
I fully get what you’re saying. But say I want to have another enemy blueprint, for example BP_NPC03, which will have different mesh and properties, yet still have it execute the instructions that are currently casting EXCLUSIVELY to BP_NPC02 from INSIDE the Bullet BP.
Whenever I add a copy of BP_NPC02 to the map, it does not execute the instructions. Only the original BP_NPC02 executes those instructions, because in the bullet it is only casting to BP_NPC02!
For this you want to use parent/child classes. What I like to do in such scenarios is have a base_npc class, and from that I will create lots of child npc’s. Then, you can just cast to base npc and do the function, which will apply to all children.
You can do the events/functions that you want all of your npcs to have in the parent base npc class. Then the customized events can be done on children accordingly.
For example, lets say I want to set every npcs speed to a variable I’ve created called MaxSpeed & MinSpeed.
In the parent npc, I just do this:
And then when I want to change their speed, for example when they perceive a player, I just call this:
And each single child npc will have their speed set to MaxSpeed variable which I created. It’s important for you to understand, when you create a variable in a parent class, the child’s will have their copy in Class Defaults which you can play around with.