Class type not passed as function argument?

This is part of my Character class, which has a equippedWeapon variable that is of type BP_BaseWeapon (the parent class for all weapons).

Here is my MP40 class which extends from BaseWeapon. It has overriden the weaponProjectile variable as ThompsonProjectile (unpictured) which extends from BaseProjectile. (Yes I know the projectile name doesn’t match the weapon, the issue is inheritance though not the names)

And finally, here is the BaseWeapon. Highlighted you can see it has a variable for weaponProjectile (of type BaseProjectile), which is the type of projectile that will be fired. In the center highlighted section is problem.

Problem: When the fire function is called, the accuracy is passed from the player, the caliber is resolved from the MP40 as 9x19 (unpictured overriden variable of the MP40), but the projectile to fire remains BaseProjectile, though MP40 has overriden that type shown in the second picture. What am I missing?

Everything correct mate. The Input just accepts BaseProjectile or children of it. You still pass the overriden Class to it.

Btw you dont need to pass the Class / Caliber you already get the correct Values from your overrides. You can get rid of those inputs entirly and use the variables directly :stuck_out_tongue_winking_eye: you just need the Player accouracy as Input.

Thats it nothing wrong there mate (just some unecessary Inputs)

Think of the Input simply as it has to be “at least” a Base Projectile Class that it can accept. Like in the Overlap function you get “at least” a Actor and you can Cast it to a “SpecificType” of Actor, if it succeds it is if it fails its something else than what you cast to.
But you will never get a UObject because its not a Child of Actor!

Okay gotcha, that makes sense. I guess I overlooked the fact that class/caliber is unnecessary. Do you have any idea then why the projectile class isn’t resolved when the fire function begins execution? It’s overriden as you saw, and I’ve got an instance of the MP40 to work with (wondered if the class couldn’t be resolved if there’s not an instance of the weapon).

I feel like an idiot, but I found my problem.

This begin play event is meant to be temporary as I intend to pass the player’s selection from a loadout screen to what the player will have spawned in the begin play. What would be the correct way to ensure that the actor is spawned correctly with the proper variables, such that this wouldn’t happen?

This was set as BaseProjectile until I changed it btw

Why did you expose all the stuff when you want to use the defaults anyway? All this will override your variables. Do it one way or the other but not both.

And why do you think the class could not be resolved? Spawn the Projectile and create a Print String On Begin Play inside the Projectile BP you expect to spawn. If it shows up everything is good. If not you changed the default in your script somewhere.