I have a custom C++ class that declares and defines variables for the character. The parent class for the character is set to the custom class. The project compiles but when I run the editor, my variables do not show up in the Blueprint editor.
having a custom c++ class and make a blueprint out of it inside editor will result that the blueprint is a child of your c++ class, that means you have to set your variables at least as protected to get them inside the Blueprint. Right now they are privat by default as duncan mentioned and because of the childbehaviour you have no access to private parent variables.
hmmm, the next thing i would try is, reproduce this issue with a new raw custom class. Are you having the same result with a variable inside there too?
Sorry if this is a really dumb answer, but I looked at my character classes and my C++ defined variables don’t show up in the upper left either. However, if I right click in the event graph, look under variables, under the category I’ve created for them, then I can get a reference to them…
Have you tried that? the only reason I ask is because the screenshots you link to focus on the window in upper left…
Thanks for the suggestion. I have tried right-clicking and checking under variables, but there is no “Power” category, the one I created for them, and the variables are no where to be found. I appreciate you taking the time to suggest that, though!
I’m not sure what your inheritance is like, however this seems to be working correctly in the current 4.7 preview 1 build.
Are you inheriting, your class HenryOtterCharacter → AGameNameCharacter → ACharacter?
#pragma once
#include "GameFramework/Character.h"
#include "AmalynCharacter.generated.h"
UCLASS(config = Game, meta = (ShowOnlyInnerProperties))
class AAmalynCharacter : public ACharacter
{
GENERATED_BODY()
public:
/** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
float BaseTurnRate;
/** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
float BaseLookUpRate;
private:
/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = true))
class USpringArmComponent* CameraBoom;
/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = true))
class UCameraComponent* FollowCamera;
/** Collection Volume */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Power", meta = (AllowPrivateAccess = true))
class USphereComponent* CollectionSphere;
/** Power level of the character */
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Power", meta = (AllowPrivateAccess = true))
float PowerLevel;
/** Power multiplier for the speed of the character */
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Power", meta = (AllowPrivateAccess = true))
float SpeedFactor;
/** Baseline speed of the character */
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Power", meta = (AllowPrivateAccess = true))
float BaseSpeed;
};
Actually, yes, I’m getting the same result. I tried creating a new 3rd Person C++ Code project and declared a new custom variable inside the Character class. I compiled the project, and when opening up the MyCharacter blueprint in the editor, the new variable can not be found. It’s as if the UE Editor is not using the custom code I’ve written when running.
Interesting. To answer the inheritance question, yes, I believe the inheritance is set up correctly, since the files I’m using for the Character class is the code the UE editor generated for my project when it was created.
I tried copying and pasting your code into my class to use it instead, and the build fails for me with the error “BlueprintReadOnly should not be used on private members”. Of course I’m using a different engine version (4.6.0) than you are, which might explain that difference. But still the variables do not show up for me in the Blueprint Graph after fixing that issue.
Just as an exercise, I downloaded the Windows version of the UE4 engine/editor along with Visual Studio and did the same thing: I created a new 3rd Person C++ Code project and declared a new custom variable inside the Character class. When I started a new debug instance and opened up the MyCharacter blueprint in the editor, my custom variable was there in all its glory. So there’s definitely something different with the Mac version of the engine and how it interfaces with custom C++ code. For example, what’s the Mac/Xcode equivalent to starting a new debug instance? Because there’s nothing in Xcode (or any of the Unreal documentation that I could find) that explains how to do that.