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"

Variable Exposed To Spawn Not Being Set at Begin Play?

(round 2 typing this because internal errors)

I have a variable Tick Rate expose to spawn that isn't being set when Begin Play is called. I want this to set the tick rate to a desired level right at object creation time. alt text


This is still an issue now on the C++ side. I have a C++ version of my actor component I'm spawning in blueprint, and variables exposed to spawn ARE NOT being set before Begin Play is called. This is resulting in hard crashes because object references are not being set before being accessed.

 // BuffComponent.h
 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
 FString text = FString(TEXT("Default Text."));

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
 class ATank *owner;

 // BuffComponent.cpp
 void UBuffComponent::BeginPlay()
     GEngine->AddOnScreenDebugMessage(-1, DEBUGTIME, FColor::Yellow, text);

alt text

alt text

Product Version: UE 4.14
more ▼

asked Feb 14 '17 at 11:01 AM in Blueprint Scripting

avatar image

101 33 36 41

avatar image apsteele Feb 14 '17 at 03:28 PM

Does your Tick Rate variable have a default value set?

avatar image GhostRavenstorm Feb 14 '17 at 08:54 PM

Yeah 0.0. Of course that changes at spawn time depending of the type of buff. This is just the parent class holding the base implementation for all buff classes.

avatar image GhostRavenstorm Feb 15 '17 at 12:39 AM

Setting values at the Spawn node is the equivalent of setting values in a class constructor, right? I'm trying figure out why Begin Play is executing before the Spawn constructor finishes.

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

2 answers: sort voted first

For whatever reason, passing through this delay node first allows exposed variable to be set properly even when its set to 0 delay. May not even have to be a delay node, but connecting Begin Play to Set Tick Interval somehow executes first before my Tick Rate is set.

alt text

more ▼

answered Feb 14 '17 at 11:15 AM

avatar image

101 33 36 41

avatar image Fotosynthesis Feb 15 '17 at 12:20 AM

Could it be that it is acting like this because you happen to set your tick rate based on world delta seconds? (which would be 0 at beginplay)

avatar image GhostRavenstorm Feb 15 '17 at 12:33 AM

Its not though. I'm setting it in the Spawn node.

alt text

I can put a print statement right after Begin Play and it would print the default value of 0, but a print statement after the Delay node and it prints the value set at the Spawn node.

avatar image Fotosynthesis Feb 15 '17 at 12:45 AM

It does seem very odd...It seems like a bug, but then again its not like you're trying to do some obscure thing..You'd think this would have been reported sooner..

Anyway it looks like you have a "workaround" Good luck :)

avatar image GhostRavenstorm Feb 16 '17 at 11:48 AM

I'd like to hear a dev response to this. I think this is a bug.

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

There are a few similar questions and some answers on the hub. Having recently run into this behavior I summarized what I found in this response: https://answers.unrealengine.com/questions/536784/expose-on-spawn-doesnt-work-for-custom-components.html#answer-661527

Note the linked answer has a dev-side answer, which essentially says, it is an order-of-operation problem. I suspect solving this issue is not trivial in the backend infrastructure. However as a developer I know that software problem problems can be solved by adding yet another layer of abstraction... which could have drawbacks... performance... complexity. Still it would be nice to get it fixed.

more ▼

answered Jul 04 '17 at 06:10 PM

avatar image

132 6 15 18

(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