x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Creating a Blueprint Member Variable with the Same Name as a Variable in the Parent Class Causes Weird Behavior

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

  1. Create New Project > C++ (not blueprint) > Third Person

  2. Create a blueprint which inherits from actor.

  3. Create a member variable in the blueprint named "lifespan" of type float

  4. 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.

  5. 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.

  6. Rename the blueprint variable from "lifespan" to something which doesn't conflict with the name of parent (actor) class member variable.

  7. Now change the default value to 1000, save, and compile. It will not revert back to zero.

  8. 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.

  9. 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.

Product Version: UE 4.12
Tags:
more ▼

asked Dec 10 '16 at 04:08 AM in Bug Reports

avatar image

Irmis Turodan
1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi Irmis Turodan,

Thank you for letting us know about this. I ran some tests and was able to see the behavior that you described. I have entered UE-39930 to have this investigated further.

Tim

more ▼

answered Dec 19 '16 at 10:17 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question