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"

Spawning different pawns based on menu selection

I'm hopelessly stuck.

I've got a menu that displays a rotating mesh, with a left and right button that changes to a different mesh. All of this takes place inside a widget blueprint. When the mesh is changed, I store the value in a string inside the widget. ShipA, ShipB, ShipC. The play game button calls some event dispatchers, because I couldn't seem to access these strings in my gamemode blueprint.

alt text

How can I make this value affect what actor is spawned when the play button is clicked and game starts? I cannot seem to access this widget and get it to spawn an actor via my gamemode blueprint at all. I can bind event dispatchers from my widget to events in the game mode blueprint and print strings but CANNOT seem to get any actor to spawn.

alt text

Product Version: UE 4.14
Tags:
more ▼

asked Apr 04 '18 at 11:08 PM in Blueprint Scripting

avatar image

tylerisit
1 1 2 3

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

3 answers: sort voted first

Thanks for the suggestions ya'll! I managed to fix this by making an empty actor in the first level that spawns my ship, but instead of looking to the gamemode for the variable to determine which ship to spawn, I put an integer into the gameinstance! Turns out the gamemode blueprint is run and defaults were being returned to every time I went to a new level. Learning!

more ▼

answered Apr 05 '18 at 08:47 PM

avatar image

tylerisit
1 1 2 3

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

I would create an array with your ship meshes, and when the player "rotates" through the ships in the menu selection I would have that store the data as an integer variable instead of a string. The reason is an integer is useful for pulling things out of an array. So with the ships info now stored as an integer, you can then "get" that specific index out of the ship mesh array depending on where it is located in the array.

more ▼

answered Apr 05 '18 at 12:16 AM

avatar image

Nebula Games Inc
5.4k 28 9 15

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

I am not entirely sure exactly what you are asking... However, I will assume that your question is "How do I connect Widget to something I can use in my other Blueprints"

Often the easiest thing to reach from Widget is Player Controller (see Ref 2) because it's passed by default via Owning Player property. That will connect a button (or any other UI input) to something you can work with on the back-end. You can then spawn different actors (in your case, different ships) from Player Controller. Look for Spawn Actor from Class node, and spawn what corresponds with user selection.

Ref: Widget Player Controller

ue4-2.png (107.1 kB)
ue4-1.png (151.9 kB)
more ▼

answered Apr 05 '18 at 01:10 PM

avatar image

gk0r
161 1 6 5

(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