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"

Best way to fire a blueprint event from an FRunnableThread?

I'm currently setting up and executing an FRunnableThread. The thread is spawned by hitting a key in Blueprint, and which calls a method on an object (which extends AActor) that was placed in editor. This actor works as a message server for a limited number of other actors; it waits to receive information from outside UE4, checks what actor it should transmit that information to, and transmits it.

However, on top of this functionality, I'd like to trigger a blueprint event on the receiving actor when transmitting a message to it, so my team's level designers can update their HUD and animate models accordingly.

Naturally, there are workarounds (eg, mark as dirty + poll to check if dirty & fire a latent event from within Tick(), which runs in a thread permitting BP event firing), but I've got the feeling I'm just not calling the event at the right time / from the right thread, or perhaps am not setting some actor flags necessary to permit the event firing from a thread.

I've created many events before from Blueprint, and it's very straightforward. So, knowing how to create an event isn't the issue - rather, I'd like to know the best way to make an event fire when called from an FRunnableThread.

Any help would be greatly appreciated, thanks!

Product Version: Not Selected
Tags:
more ▼

asked Oct 19 '14 at 05:57 AM in C++ Programming

avatar image

nesis
31 4 6 9

avatar image nesis Oct 19 '14 at 06:35 AM

Hmm, never mind me - after some further troubleshooting, it appears that the server's client actors were being duplicated :) Will post back to confirm whether avoiding this duplication fixes the problem.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

My issue was that I was getting a reference to an in-editor object during PIE, by mistakenly using TObjectIterator<> to iterate through all instances of my custom actor class. Since my code had a reference to an in-editor object, I wasn't getting any errors when trying to invoke Blueprint events for it.

I would normally have fixed this issue by instead using TActorIterator<>, which iterates only over PIE objects when playtesting in the editor. However, since that method requires use of GetWorld(), like such:

TActorIterator actorIterator(GetWorld());

... it's not usable outside of the main game thread. Since my FRunnableThread code executes outside of the main game thread, I had to make a different solution.

In the end, I settled for managing a TArray<> of instances of my custom actor class. That TArray is stored as a static member of my custom actor class. This way, my server class can access that static member to collect references to the custom actors as needed.

more ▼

answered Oct 19 '14 at 09:20 AM

avatar image

nesis
31 4 6 9

(comments are locked)
10|2000 characters needed characters left
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