I wanted to decrease the weight of the file size of my player blueprint by making the Camera Parameter Changer function as a generated as an Actor Blueprint. I wanted this blueprint to be always active via Cast To, but I’m having problems with this warning:
The “Player Camera Target” variable inside the CameraParameterChanger BP has a Variable with the same Player Target (BP_Player_001) connected with Camera and Spring Arm component getters inside it.
That doesn’t tell me much. Which ref? An actor?
I already tried with Player Blueprint, Pawn and Controller, but still getting “does not inherit” warning.
Object Type as the CameraParameterChangerBP in variable inside Player Blueprint is definitely out of the game, as “You don’t need to cast to” note pops up.
I tried creating the Reference Variable, so I could have the Cast To’s Object pin connected with it, using the variable of Player Blueprint, but I always end up with the Cast Failed.
I also tried to place the Camera Parameter Changer BP in the world/level, but ended up with the same: Cast Failed.
I’m actually trying to make it to be internally activated (forgot to mention it). Without the need to be placed in the world/level.
The “CameraParamChangerRef” is a Reference Getter Variable inside my Player Blueprint, with the Getter connected to Object pin of Cast To CameraParameterChangerBP.
I’ve connected the CameraParameterChangerBP object type variable, and I’m back to square one: I got “Is already CameraParameterChangerBP. You don’t need to cast”. And the cast continues to fail.
Can’t connect to Object pin the Player Blueprint because “it does not inherit”.
Can’t do the same with CameraParameterChangerBP object reference variable, because “I don’t need to Cast To”.
“I’ve connected the CameraParameterChangerBP object type variable, and I’m back to square one: I got “Is already CameraParameterChangerBP. You don’t need to cast”. And the cast continues to fail.”
this is telling you, you already have the variable, so remove the cast and just pull off the REF to have access to its functions
As per always with this kind of thread which there now are hundreds of, if not more.
Creating a variable is not the same as instantiating an actor. A variable is just an address of an actor instance, or another name it can be known as. But which actual instance do you mean? What if there are 5? You must to tell the editor which actor instance specifically you wish the var to refer to.
Where is your actor instance, how does it make it into the game? That’s what is being mentioned above by Setting - assinging value (actor instance) to a variable.
Okay, I’ll try to be clear this time, because I’m sitting on this and growing mad.
I made the CameraParameterChangerBP as a separate Blueprint with Parent Class: Actor, so I could decrease the file size of my Player Blueprint (BP_Player_001).
To make it work, internally, keep this optimized somehow, and to be always active without the need of placing it into the world/level, I tried using Casting To, but that failed, because it needs an object “it needs, but also rejects” because “it does not inherit them”, ref to Player Blueprint (BP_Player_001) for example.
And solely using the Variable object type reference of CameraParameterChangerBP, as a Target for the “Player Camera Change Parameters” event, made things worse, because it can’t access the blueprint. Even when its placed it in the world, and I keep triggering the Initial Function Setup with keybinding.
As for the CameraParameterChangerBP, for the Targets for the components inside I can’t have other target than ref to Player Blueprint (BP_Player_001).
Just what else I can try?! Change the Parent Class of CameraParameterChangerBP? I’m losing my mind!
How do you spawn that actor then? You need to instantiate is somehow, like everything else. Do you Spawn Actor from Class?
And solely using the Variable object type reference of CameraParameterChangerBP, as a Target for the “Player Camera Change Parameters” event, made things worse, because it can’t access the blueprint. Even when its placed it in the world, and I keep triggering the Initial Function Setup with keybinding.
Again, a variable is not an actor. Actors sits in the computer memory, the variable stores the information regarding where. Imagine you have a house, and an address of a house written on a piece of paper. That piece of paper is the variable. But where the heck is the house, though?
the stuff in the Content Browser are just blueprints (templates) for actors
you take a BP and make an actual actor instances out of it - either by placing it in the world (which you do not want) or spawning it dynamically
you can then, optionally, use a reference variable to keep track of it, so you can access it
But a reference variable will be null until you assign it value - an instances of an actor. Creating a reference and not assigning it value achieves nothing. Think about it - create a string variable and do not type in any text. What do you get? An empty variable, just like with your CameraParameterChangerBP. It could hold text, but which text?
Also:
I made the CameraParameterChangerBP as a separate Blueprint with Parent Class: Actor, so I could decrease the file size of my Player Blueprint (BP_Player_001).
This does not make much sense. I don’t think you need to worry about (the wrong thing anyway) it. Make the product first, optimise later. If you want to explore this particular route, the keyword is soft references, just make sure you first wrap your head around the fundamentals of OOP.
Been tinkering a little, since I see, there’s no way I can get the blueprints to be activated internally (without having to be placed in the world/level).
Decided to put Get Actor Of Class node in both Player Blueprint and CameraParameterChangerPB, and create a PlayerStart with Camera Changer Actors tied to it (as a children), to make things a little more… handy.
This has nothing to do with casting, casting is never the problem. You do not know how to obtain a valid reference - once you have one, there’s no need to cast… Get Actor of Class will only work if there’s a single instance and it’s fine to use if that’s the case. However, how are you going to deal with the rest of the communication? 90% of programming is about moving data from a → b. If you ever feel forced,to use Get (all) actors of Class to fetch and important BP instance, something has already gone wrong. You mentioned optimising - Get Actor of Class is the very opposite.
Perhaps that’s something to focus on in the foreseeable future. Do consider it: