Calling another class/blueprint from a blueprint - what are these sections for?

If you look at the above question’s answer, there are two images, and I’m trying to replicate what is seen in the first, but cannot understand what is going on there. Why do I need to get actors of a class and what is the GET module in-between that and the cast to another blueprint, and how do I find it in search?

I’m simply looking to initiate an event from a blueprint, to be cast to a class that it does not inherit from, so that the blueprints that inherit from this class can have this event executed. And I’ll be passing a string variable along the way as well, but I think I have that set up just fine.

Hello.

In the first picture in the link you shared, Get All Actors of Class is used to basically get all the Actors in the scene which are of the class type specified in the dropdown. Since there may be many Actors of that specified class, there will, of course, be many Actors to return from the Get All Actors of Class node. The way this node returns them is in an Array (That’s why the return node looks like a square made of smaller squares - that’s a symbol indicating that this node returns an Array). Normally the return node looks like a blue circle, like the As Projectile Base return node on Cast To ProjectileBase you’ve got there.

So since Get All Actors of Class returns an array, the GET node will retrieve a particular element from that array. Notice the get node has a number box with 0 in it. This is the index of the array. Arrays start at 0 so this is saying GET the first (0th) element in the array and return it.

So basically in that example, the way the Actor is accessed is through Get All Actors of Class (not a very efficient way, since it does what it says, gets ALL actors of the specified class which could be many) and then after that, it casts it to whatever…

Also rather than finding GET in search, just drag off of the square looking node on Get All Actors of Class and type GET. That should work.

Also I’m noticing you already are getting actors of the class ProjectileBase, so I wouldn’t think you’d need to cast it to ProjectileBase. It’s already the type you want. So you can just use GET, indexed at 0 (and this will retrieve the correct one if you’ve only got a single ProjectileBase instance in the world) and then simply call the function from that blue return node from the GET node. The blue return node is the ProjectileBase object retrieved from the Array returned by Get All Actors of Class.

Hope this informed you on the mechanics of those nodes you’re using.

It’s hard to answer your question as you still need to build up a lot of basic essential knowledge.

You should watch this amazing video called “Blueprints Communications” by Epic:

https://youtu.be/EM_HYqQdToE

it’ll answer all your questions and teach you everything you need regarding this topic.


In any case;

What’s going on is that the “get all actors of class” node will look for all the actors of the specified class currently existing in the map and will return an array (a list).

“get 0” gives you the 1st actor of that list (arrays start at 0, not 1)

What you get is what’s called a “reference”, which is like a hyperlink to the actual actor in the world.

Through the reference you can “peek” into the actor and call it’s functions.


When using “GetAllActorsOfClass” there’s usually no need to cast to the class, as it is that class already. Casting is used to try and specify a child class from its parent class.

sorry, the link took the “,” as part of it. spaced it better now.

you don’t need to cast to the child class, you can just the all actors of class with that class to begin with.


to be able to call a c++ function from blueprint is must have

UFUNCTION(BlueprintCallable)

the function must not be private.

public would let you access it from anywhere

protected will only let you access it from a child class.

Says this page is not available, is it country-locked?

And yes, I am looking to cast to all child blueprints of the class that I have specified. I found this, which may be the same or a similar video: Blueprint Quickshot: Blueprint Communication | 05 | v4.7 Tutorial Series | Unreal Engine - YouTube

But even with that I cannot get what I want going. For some reason, even though I have set up the event FiringSetup in c++ class, the blueprint that inherits from it cannot access it (even though I have UFUNCTION set for it), and I have done build on visual studio too to make sure this applies, even restarted UE4, still nothing.

I’m setting pretty much everything to public because I can’t deal with the issues that protected and private variables will give me while I’m trying to do the most basic of things, so don’t worry about that. I realise it’s pretty hard to explain what I’m trying to do, so I’ve made this diagram to show exactly what I’m trying to do. My issue is getting the first blueprint to tell the class to execute the function so far.

That video did not help me at all to understand how to do what, unfortunately. I’m also having issues where, even though I’ve built the visual studio files, restarted both VS and UE4 multiple times, I can’t see FiringSetup event in the list on ProjectileRifle blueprint. I’ve created a new event with that name on it, but I don’t think this is going to work. And yes, I have set up this for the function:

UFUNCTION(BlueprintCallable, Category = Firing)
void FiringSetup(FString directionFace);

Also, why does the cast require an object input? I’m calling to ProjectileBase, so I’ve identified whom I’m talking to, why do I need to throw some random object reference? The class I’m casting to is the class I want to talk to, I don’t want to pass in any objects. May be I don’t even need to cast and I’m doing something completely wrong, but I can’t tell.