Getters and setters

  1. When you expose c++ variables so that they can be used in blueprints does it automatically set up the get and set nodes for it ?? or do you have to do these manually yourself and if so how?

  2. Is it possible to edit a current engine parent class to have youre own variables or just modify the existing ones? For example can i edit the parent actor class so that when i create my child classes from it they will inherit the changes.

Ive noticed while blueprinting that there are a lot of exposed variables and nodes where you can only get the variable name and value but not set them .

Thanks

  1. No the UPROPERTY’s have to be public don’t they, so no setter/getter is required.
  2. You’d have to derive a common subclass yourself from the engine class, and use that as the base class for all other classes.
  3. That’s probably got something to do with the UPROPERTY attributes being read-only for example.

trojanfoe is mistaken on a few points there.

1 - If they’re either Protected or Public, then yes. I can’t remember off the top of my head if Private vars will expose to BP properly too, but I can’t think of a reason why not. They need to use the UPROPERTY() macro. BlueprintReadOnly allows a get only, BlueprintReadWrite allows a get and set. UPROPERTY() can be used on variable whether public, private or protected.

2 - The way to get around this really is by using Actor Components, just add your component with all it’s vars to the Actors you need. You don’t want all crates in the world to have an ‘Inventory’ property for example :slight_smile:

3 - This is due to what I said above about the UPROPERTY() macro arguments.

Ah, OK I made an assumption there. Thanks for clearing that up :slight_smile:

thanks for the replies. So it basically depends on how you set it up with the keywords and the macro. Cheers

Yeah thats what i have been doing just making a base class derived from a parent class then adding my own stuff

What i kinda meant is things like the player state class, you have for example
A variable for the player name but you can only get the variable there is no setter to actually change or use the variable . So would i just need to go into the class and change its UPROPERTY macro arguments . I know i can just make my own player name variable but just seems silly there are things there like that which already exist so why not use them.

Thanks.again