all the game code is setup around the playercontroller casting the game UI into the 3dwidget actor, (when it was a 2d game it was added to the player viewport.) If I just add it into the 3dwidget actor I get a load of errors. So is there no way to reference the button click if I’m using the player controller to cast the UI?
As above, have whatever you need reach out to the PC once it has referenced the widget.
OK when you say PC you mean player controller. Get it. I don’t know what you mean by entitys or delegates though. So if I put a reference to the PC into the game level what do I do with it?
Is this not your player controller?! Providing you have a Game Mode that is assigned a player controller, you Get Player Controller
.
Sorry so many of the BP sound the same and I’m going around in circles here. Forget about my last screenshot. So the BP_TowerdefenseController is in the level. The BP_TowerDefensePlayerController is not so I’m guessing referencing the button click in the Level BP is not possible so If I have to reference the Player Controller that is casting the Game UI into the 3D Widget and which the BP_PlayerCardSelection is referenced in the BP_GameUI then where do I need to reference the PC. In which BP and what Nodes do I need to use. I understand if this is to much of an ask for you to be honest I’ve almost given up on being able to do this by now.
If you’re using a proper Player Controller in the Game Mode, it’s available from anywhere, any blueprint can:
Cast to the right class.
How did you reference player card selection?
By adding it as a variable in the PC
Could you clarify what this means? Creating a variable does not reference anything on its own. You need to set the value. Can we see how you do it?
You’d do it right here. I admit, this whole thing is a communication nightmare.
Creating a variable is not enough. It’s null, hence the errors. You need to assign (Set) its value. That’s what the Return Value pins on Create Widget / Spawn Actor / Add Component nodes are for.
Imagine you created a string variable but never typed in any text. You sure do have a string but it has no value. That’s the null value reference you have is, atm. It could point to a widget, but you need to tell the editor which instance you mean.
Ok so I think there is a mix up between what you (and probably everyone else) mean by “set” and what I mean by “set” because I showed you an example of me setting the variable before and you said that was worse. So when I think I need to “set” something I literally drag the reference out and there are two options “get” and “set”
and usually set it after an event begins play like this
but that doesn’t work so when you say I need to “set” it can you show me an example of what I need to “set” and where I need to put it?
You need to plug in the value returned by the node that creates the object. Please read above.
What you’re showing atm is dereferencing. The opposite.
When you say Value. What Value are you talking about? When you say node. Which node are you talking about? When you say object. Which object. I did read above. Your asking me to set something but not telling me what it is I need to set? I showed you an example of what I think setting is. Can you show me an example of what you mean?
When you create an instance of any object dynamically, the node that created said object returns a value of the specific type:
We assign that value to an otherwise Null
variable so we can later on, in this BP or elsewhere, refer to that instance of an object:
This is the very core of OOP one cannot do anything without.
You can see it here:
If you did this:
You would have removed (dereferenced / cleared) the value of that variable so it no longer points to an object (in case it was, but it wasn’t to start with…)
Were you to follow the docs link above, you’d very quickly run into:
Which dramatically simplifies the process so you do not even need to create variables laboriously yourself.
Thanks for explaining and also the time you took to help me.