How to get Camera Location and Rotation in C++ if my Character Class is in Blueprint

Since you added the component in the blueprint version of a class, you can’t use any references in C++ that were automatically created by that blueprint such as MyClass->FollowCamera, because as far as C++ is concerned that property isn’t declared and so doesn’t exist (and technically it doesn’t.) What you can do is try finding the component by class in the actor and then store that as a new reference in C++.

The straight up easiest thing to do though is to define your references in C++ as a parent class and derive the blueprint part of your class from that. That was UCameraComponent * FollowCamera exists in a C++ class and so C++ can reference it directly (and so can your derived blueprint.)

1 Like