Pretty new to UE4 and all that. Been doing some BluePrint-ing to try it out and it’s pretty logical. Like any language you don’t know fluently, you know what you want to say but not exactly how to say it.
Made a cube that chases me down and which I can destroy by shooting it. It also drops items now and then, 30% chance for an item to drop.
I feel like I should extract some of my BP-code to be universal for a type of object(?). I mean, if I make new enemies then I don’t want to have a drop function in every single one but rather one drop function that I call for whatever item that drops. Every item has its own drop rate.
My thinking was to make a pawn with things in common for every item and from that pawn create new children. Something like:
Item having a drop function which return a boolean if it should drop.
The child having a variable that’s drop rate which modifies the drop function in item.
So when my cube is destroyed (or right before), it might drop an Apple. Before the cube is destroyed, it asks the Apple if it will drop, the Apple ask the Item “Hey Item! I have a 30% chance to drop, will I drop?”, then the Item respond to the Apple saying “Yeah, why not? Do drop” and the Apple tells the cube that yes, it will drop. The cube dies (gets destroyed) happily.
First question, is this the right line of thinking? I really like the concept of DRY (Don’t Repeat Yourself) and figured that if something repeats within different BP then they should be abstracted to something above, like a parent.
Second question, how do I communicate between BP? I’m trying to run my drop function but I don’t seem to be able to reference it.
Been browsing around a bit trying to figure it out with casts etc but I have not found anything helping me with the above. Hence starting to questioning if I’m even thinking in the right direction.
Thankful for any help or pointers