NEED HELP: Casting To Actor Function Blueprints

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.

You need a REF to the CameraParameterChangerBP and then set PlayerTarget on that.

1 Like

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.

Here’s the Graphshot of CameraParameterChanger Function Actor if it’ll help.

1 Like

Okay, here’s some more data, if it helps, since I’m in an pitfall I can’t get out from.

Camera Parameter Changer BP


The variable Camera Owner Target has my Player Blueprint (BP_Player_001). I couldn’t find the other way for targets to the components.

Initial Functions Trigger inside my Player Blueprint


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.

1 Like

As i said a REF to Camera Parameter Changer BP.

You must be spawning or creating it somewhere, when you do this it’ll return a reference to that object.

Or if you want the simple but inefficient version use GetActorOfClass() Just make sure it exists somewhere in your world

2 Likes

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”.

1 Like

“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

1 Like

Disconnected the Cast To.


“Accessed None trying to read property: CameraParamChanger_BP”.

so now you need to set the variable, where is it created?

you said you dont want to place it in the world but its an Actor, it has to be placed in the world.

Other potential options, use a UObject, or use a function library?

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!

We understand what you’re saying, you’re not understanding what we’re saying.

  1. You made it an actor

  2. An actor MUST exist in the level.

  3. IF it exists you can get a REF to it.

  4. I doubt this optimizes anything, it must exist so if you need it so it may as well just be on your Player

1 Like

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.

1 Like

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.




It seems to be working now.

Sorry for freaking out like this, I guess I just can’t rely on Cast To node all the time.

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:

Good luck!

As said earlier if you dont want it to exist in the world
construct a UObject or possibly even Actor Component

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.