[BUG?] Expose on spawn variableS can't be used after(this) function

I’m not sure if i don’t know how to use it , or this feature isn’t avaiable. However , pictures talk more than words, here’s what happening

This is the function, but i can’t choose the expose on spawn AFTER calling it , this is what looks like

123380-2.png

However, choosing to spawn the desired actor within the function allows me to use the expose on spawn variables, like this:

123381-3.png

Is this a bug? If not, could this feature be implemented?

Your function called Shoot probably has a type of Actor instead of a type of Arrow for the test parameter. Change the test parameter to have a type of Arrow.

In order to see the expose on spawn parameters that you created, you need to make sure the Actor class you are passing to the Spawn Actor from Class node is casted to your custom actor class.

I’ve done that already, but i was trying to create the shoot function for everything.
Bow and arrow, shotguns. sniper rifles, automatic rifles, pistols, etc… However, having to do that i need another function / a branch node. Simple solution but would be nice to have this feature implemented

But the problem isn’t that it’s a lack of “feature” rather that’s not how object oriented programming works.

If you have a Bullet actor that inherits Actor and an Arrow actor that inherits Actor and you call Spawn Actor From Class and you pass in a class that is of type Actor, how does the compiler know whether the actor is an Arrow, Bullet, Character, Pawn, GameState, GameMode, etc class? Because all of those classes I listed inherit from Actor. This is why in object oriented programming there’s polymorphism.

Here’s what you should do: Use a blueprint interface or inherit a parent Actor class. (Use interfaces to describe behavior and not the data they contain)

Using an interface
Create a blueprint interface called BPI_Projectile and add functions to it that describe a projectile. Some example functions in this interface would be GetSpeed, SetSpeed(float speedParameter), GetVelocity() SetVelocity(float velocity), etc.

Update your Arrow, Bullet and other “projectile” Actors that are spawned by your Bow and Gun so they implement your new BPI_Projectile interface.

Now in your Shoot function you can spawn the projectile actor that was passed in as a parameter, take the Spawn node’s return value (of type actor reference) and try to cast it to BPI_Projectile. If you successfully cast the actor to a BPI_Projectile you can take the BPI_Projectile reference and make the interface call to SetSpeed(). In SetSpeed() it would set the speed and move/update the moving speed of the actor.

Using a parent class
Create a new blueprint Actor that inherits Actor and call it BP_Projectile. Create your Speed exposed on spawn variable in this actor class.

Update your Arrow, Bullet and other actors that are “projectiles” so they inherit BP_Projectile instead of Actor.

Update your Shoot function so the class parameter type is of type BP_Projectile instead of Actor. Now the compiler/editor knows that the Actor has a Speed parameter.