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"

In Level Blueprint, how to create references to Actors spawned at runtime?

I have a GameMode that spawns different (1-4) controllable characters at runtime. I would like to use the Level Blueprint to switch pawn possession using hotkeys (1-4 for example) like in this tutorial.

How can I instruct it to search for characters, add them to a list/array of references, and then enable the hotkey swap like in the tutorial?

Thanks in advance.

Product Version: UE 4.10
Tags:
more ▼

asked Feb 26 '16 at 05:16 PM in Blueprint Scripting

avatar image

ClaudioPiccinni
226 23 20 24

avatar image danilo.afx Sep 17 '17 at 01:31 PM

Can someone explain this using images? "Save their references inside GameMode after spawning, then call GetGameMode inside Level BP, cast to your type and you can get the references."

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

1 answer: sort voted first

Save their references inside GameMode after spawning, then call GetGameMode inside Level BP, cast to your type and you can get the references.

more ▼

answered Feb 26 '16 at 07:50 PM

avatar image

phoboz
998 37 13 60

avatar image ClaudioPiccinni Feb 29 '16 at 12:04 PM

Hi Phoboz, thanks for answering. I'm trying to do as you said but I'm not quite succeding. How do you save a reference properly? I'm using 'promote to variable', but when I get this variable from outside the gamemode it gives error (invalid target).

avatar image phoboz Feb 29 '16 at 12:16 PM

Can you show your blueprint where you save and get the reference?

If you use BeginPlay to both, spawn and get the reference, it's possible that getting script is executed first, before the Actor is spawned. In that case you can look into BP tick ordering or use a small workaround and put Delay node with a tiny value (possibly even 0) just before getting the reference

avatar image ClaudioPiccinni Feb 29 '16 at 12:26 PM

I was not casting the GameMode correctly. It works now. Thank you very much phoboz :)

(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