First, I think the editor should not allow a user to give a blueprint member variable the same name as a member variable in a class which the blueprint inherits from. However, given than Engine v4.12 does allow it, some weird stuff can happen as a result. To reproduce one such error, do the following
-
Create New Project > C++ (not blueprint) > Third Person
-
Create a blueprint which inherits from actor.
-
Create a member variable in the blueprint named “lifespan” of type float
-
Note that the actor class already has a member variable named lifespan. Thus, creating a “lifespan” member variable in the blueprint is weird. Hopefully future versions of the Engine won’t allow it.
-
Next, in the details window pane, try to set the lifespan’s default value to 5. Save and compile, The defualt will get reset to zero.
-
Rename the blueprint variable from
“lifespan” to something which
doesn’t conflict with the name of
parent (actor) class member variable. -
Now change the default value to 1000, save, and compile. It will not revert back to zero.
-
Run the game where there is an
instance of the blueprint in your
level. The instance will be destroyed
after 5 seconds. This is because
we have managed to overwrite the
default value for the lifespan
member variable inherited from the actor class
by temporarily creating a variable
of the same name in a blueprint
which inherited from the actor class. -
To check, you can edit the blueprint event graph so that on every tick getLifespan() is called, and gets printed to the screen. You’ll see it counting down: 5, 4.4733838, etc… down to zero.