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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Spawn actor using Async task

Hello, I'm was just wondering if it was possible to use a Async tasks to spawn actors, and if so, how I would go about it. I know that you cannot spawn or delete assets on separate threads from the game thread, but I'm not sure if you can do this with Async tasks.

Product Version: UE 4.15
Tags:
more ▼

asked Feb 18 '17 at 02:16 PM in C++ Programming

avatar image

Jon Langford
69 16 14 15

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

1 answer: sort voted first

I use Async tasks to do various things like spawn particles(which has an allocation), play sounds, and other such simple tasks. The basic UObject allocation is thread safe, but I think the problem you'll run into is that the Actor you are trying to instantiate may not be threadsafe itself (e.g. It makes assumptions that its on the game thread and is running synchronously and not during some other task like Physics update or such).

If the actor is very simple (directly inherits from AActor and nothing else), I think you'll probably be fine. I wouldn't try to instantiate something like ACharacter or APawn on an Async Task (if you wanted something like that, I would just preallocate X of them on start up and re-use those X over and over).

In short, the basics are threadsafe, but that doesn't mean an Actor itself is. As for creating it, you use the same methods: CreateObject / SpawnActor

more ▼

answered Feb 18 '17 at 02:35 PM

avatar image

ExtraLifeMatt
1.6k 34 14 48

(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