I’m a bit confused on the meanings of some of the specifiers like VisibleAnywhere, VisibleDefaultsOnly, EditableAnywhere, etc… What would be the best situations to use one over the other.
It’s described in text but I still am not entirely sure which parts of the editor things end up being visible or editable from. I’m trying to clean up my code and make my classes easier to work with. I sometimes have properties end up being editable that shouldn’t be editable and I’m trying to reduce all the clutter.
I’m also looking at Unreal Tournament C++ code for reference a lot and am sometimes surprised by an unexpected setting, which makes me even more confused.
Why is the CollisionComp VisibleDefaultsOnly while the ProjectileMovement is VisibleAnywhere? Seems a bit inconsistent. Also I’m a bit confused why they’re marked Visible and not Editable. I’m still able to edit them in Blueprint.
EditXXX means the variable is meant to be changed in the editor while making the game. Note the word “Edit” , implies editor stuff.
EditDefaultsOnly Allows you to set Only a default value for a variable in the blueprint window which will be same for all objects of the type. You cannot change this variable in editor after you’ve put it in the map.
EditInstanceOnly Allows you to set separate values of the variable for every object you place in the map , but you cannot set it in blueprint before you put it in the map, The default value for this variable can be set in C++ constructor.
EditAnywhere Allows both of above!
As seen Editxx will allow you to edit the variables defaults value but will not allow you to read or write its value in a Blueprint Graph
To be able to read or write a variables value in Blueprint Graph or Logic you’ll need BlueprintReadOnly or BlueprintReadWrite alongside the EditXX like (EditDefaultsOnly,BlueprintReadOnly)
BlueprintReadOnly or BlueprintReadWrite Controls whether the variable show up in graph nodes.
VisibleXXX indicates where your blueprint variable should be visible , Visible as in its value and representation and not scope visiblity. but you cannot change its defaults value.
Whether you can read write a Visible marked variable depends again on BlueprintReadOnly or BlueprintReadWrite
Now you’d wonder why some components are marked (BlueprintReadOnly , VisibleDefaultsOnly)
In this case you’re not allowed to change the variable itself since its Marked BlueprintReadOnly . The variable here is a pointer! A pointer to your component!
So you have privilage to edit the properties in the component itself because they belong to the component and not the actor , But you cannot change everything your variable is pointing to in the defaults.
You need VisibleDefaultsOnly with it so that you can actually see it in the defaults window before changing component’s properties and BlueprintReadOnly Makes sure you don’t make changes to component as a whole!
If you mark it as EditXXX then all the properties of the component as a Variable will be exposed. Which we don’t always need
I actually perfectly understand BlueprintReadOnly/ReadWrite.
The snippet from Unreal Tournament I provided has one component marked as VisibleEverywhere while the other is VisibleDefaultsOnly which I’m a bit confused about. They’re both marked BlueprintReadOnly. It could just be a tiny mistake on their part.
Thing about Projectiles is they shouldn’t even be placeable anyway so if I understand correctly VisibleEverywhere has no effect since you’ll never see the option to edit the InstanceOnly. Maybe I’m just getting confused by them being lax with how they use the specifiers in some places if that’s the case.
Or is it that if it’s BlueprintReadOnly but VisibleEverywhere, can I instantiate the projectile in code, and then access the MovementComponent and set its velocity? In C++ I’d understand this like a const pointer that I can’t change the value of but can access the pointer and change values in the thing it points to, as opposed to a pointer to a const object that I can’t change.
That allows you to set properties of the projectile movement anywhere whether in an instance or in the blueprint.
As for why its marked VisibleAnywhere is for the purpose of testing , When you want to see if your projectile will behave properly or not you just put it in the map set the properties of the projectile movement and as soon as you hit play the projectile movement will send it flying as if it was fired by a gun.
If you don’t like it you can then readjust the projectile movement properties and try again. Or put two projectiles side by side in the map and change properties of their projectile movement and see the difference between flight of the two.
So I believe its just for testing purposes during development
That allows you to set collision shape size and stuff, the developer didn’t want to test different sizes of sphere I suppose, so it was marked VisibleDefaultsOnly