ie using GameCamera, CodeGameCamera, PController, and CodePController:
Add Variable named PControllerRef
Change type from dropdown
Hover over the list
You can now store a variable there at runtime (ie when spawned by the player controller) ; Now I can reference my playercontroller ezpz.
ASSUME ALL OF THESE HAVE THE FOLLOWING ABOVE THEM:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ReferenceVariables
Edit: I’ve also tried this with the code versions of PController. I’ve created my blueprint classes by deriving them from a code class of their same type; just so that I can add functions and whatnot for the heavier stuff that’ll benefit from C++ performance improvements)
None of these work. All I’m trying to do is create a container for an instance. In this case it’s a reference to the player controller that spawns a camera. In other instances it’s going to be the character a piercing bullet has hit (or an array of them or w/e). Point is, I really need to know how to do this. It’s a huge limitation and has forced me to write a couple functions rather than using full c++ just because I can’t figure out how to get these references to work.
#1 I knew that but I’ve been up and down Google all day today and one of the things that I saw was with the asterisk over there and, even though it made no sense, I tried it just in case. #2 I kinda figured which is why I tried giving them the code based classes. Which were refused. That was the very first thing that I tried.
That said, while I understand that it has NO idea that my BP classes exist why can’t it know about them once I’ve compiled? Meaning, what prevents it from eventually seeing them at runtime? I have a vague, obvious understanding (THEY’RE NOT THE SAME and blueprints don’t seem to ever compile down to C++) but is there any way for me to do what I’m trying to do in C++?
To be clear, what I’m trying to do is:
Spawn a Camera actor (not component) via my Player Controller. I want the camera actor to have a reference to my player controller so that it can get the pawn. There are other ways to get it but I need the variable to be stored eventually.
Use the Controller reference to “GetControlledPawn” and store that reference as the camera’s “Target”.
Using the Target reference, get the player’s location and do camera stuff. With math. Math that really should be done in C++.
Worst case scenario I can just do what I’ve been doing. References and actors in BP. “Get Actor location” and pass it in a vector to a C++ function. Just figured there might be a way to do this without having to use what seemed like a “hacky” workaround.
Thank you VERY much. Not only was this (very very close to) what I was looking for it also taught me (indirectly) more about the -> vs :: operators and I’m now ages ahead of where I was when I typed this up simply because I’m spending less time looking things up and more time guessing (correctly) what the names of the calls/functions I’m looking for are. Before this I was almost never using the -> as I didn’t quite “get it” before. Used it to access some stuff in normal C++ but in UE4 I thought that it was replaced by the :: stuff. So. Thanks. Clearly I still need to keep learning C++.