Member Functions UE5
We are going to be learning about functions that exist not on the level blueprint.
In the spawn projectile function use our bp_projectile instance. We would like to move all of the functions below into our bp_projectile itself.
- Object Oriented Programming — Functinos living with the data that they manipulate.
If we open our bp_projectile class we are going to create a new function. This function will be called print your name.
- Member Function — a function on a class, always called on an particular instance.
We are going to get the name of each bp_projectile we fire. We are going to bring the print your name function into our level blueprint by dragging it into our level blueprint. From there we are going to connect our bp_projectile to the target.
If you go back to our Bp_Projectile blueprint there is no node. We can get a target of self by right-clicking and typing self. From there we can get the disaply name of our target and print it to the string.
We can see the name is different when we fire.
- Self = A node available in member functions, always points to the current instance.
We’re going to make a Launch function on the BP projectile and cut and paste the nodes over. We’re going to try and see if we can compile to check for errors. Try to fix error with self node. Call function from the level blueprint.
We have now applied member functions to our code.