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"

SpawnActor Get data from Other Blueprint without using event

Here is my approach for solving issue. Please feel free to add any comments or suggestions. .. ; ]

1- Assume you have a Spawner blueprint class. This class make numbers of SpawnActors at runtime. Each Actor has a “Public Blueprint variable” named ID, which will assign to a number at “Spawn” time. Also, this class continuously generate random numbers on Tick and assign it to its public variable which is ID.

So in short, it Spawns couple of Actors with ID and has a random number generator on Tick event.

alt text

2- You need to add this class (spawner) to stage from editor. It should be there before running game.

alt text

3- In Actor class (which you are going to spawn), you need to use “Get All Actors of Class” on Tick and get your Spawner blueprint and put result in an array. It will be just one because you add just one spawner to stage. From that array simply get the first element and easy use public variable of your Spawner which is ID,. you can use this in scenario like, if that random number matches with the ID of you Actor, then you can play some functions thou.

alt text

In this approach you don't need to use ANY event dispatcher.

Product Version: UE 4.17
Tags:
12.png (342.3 kB)
14.png (304.8 kB)
16.png (560.2 kB)
more ▼

asked Nov 06 '17 at 03:33 PM in Blueprint Scripting

avatar image

emperor_katax
60 5 9 14

avatar image Everynone Nov 06 '17 at 03:42 PM

What's wrong with Event Dispatchers? Why go through all this? Honest question.

If you're going through all this, you might as well create the spawner in the GameInstance which the LevelBlueprint (and everything else) can access.

Also, this is not a question, right? You're just sharing your experiences?

In Actor class (which you are going to spawn), you need to use “Get All Actors of Class” on Tick and get your Spawner blueprint and put result in an array.

Why? This is truly baffling. GetAllActorsOfClass is generally a bad idea, used in Tick is pretty weird.

Sorry, not getting any of this XD

avatar image emperor_katax Nov 06 '17 at 03:52 PM

well , yes, this is just my experience ... I try to use event dispatcher from Level Blueprint , but no luck ... the Actore class is a pawn with one sphere and as you see just a skeleton mesh... I agree with you, Tick is not ok .... How to make it by event dispatcher.. ? , I go through many posts and well, they didn't match to my case ...

avatar image Everynone Nov 06 '17 at 04:10 PM

So what are you trying to do, precisely?

Do you want an actor that you've placed in the level blueprint communicate with an actor spawned at run time?

avatar image emperor_katax Nov 06 '17 at 04:20 PM

.dude, many thanks for your attentions .... : ) ,,, ..I have a JSON stream which continuously send me data. I simulate that random data with a C++ class from Actor. Then made a blueprint out of it and spawned 2 Characters on stage and also gave them an ID as you see....now, I want them to get that random streaming data from my spawner class ...
How you role this with event dispatcher? .. .. I tried many ways but it doesn't give me a source/reference/object to Bind that event in Spawned objects ... or maybe I miss something here thou ....

in C++ we can assign DELEGATES in game mode and it does the job , but ... how in Blueprint ..?

avatar image emperor_katax Nov 06 '17 at 04:52 PM

@Everynone ... a good update on my blueprint , is to have a reference of spawner ,,, get read of Get All Actrs and directly get BroadCast Value out of it on Tick ... but how I reach to such a reference to spawner? .....

avatar image Everynone Nov 06 '17 at 05:12 PM

In the GameMode, create a reference to your spawner - it will be null at the moment.

Place the spawner in the Level, as you did. In BeginPlay (still level blueprint), Get GameMode -> Cast to the extended class -> set the Spawner reference to the object.

You can, of course, spawn the spawner dynamically, too, working around the LevelBlueprint shenanigans altogether.

avatar image emperor_katax Nov 06 '17 at 05:15 PM

... give me time ... `ll try now ....

avatar image emperor_katax Nov 06 '17 at 05:26 PM

cast to Character_BP and Class ... ?

alt text

alt text

18.png (97.2 kB)
19.png (128.6 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I thought you wanted your spawner placed in the level blueprint...

alt text

edit: when I said 'cast to class' I meant your extended game mode, sorry for the confusion, my bad

capture.png (85.2 kB)
more ▼

answered Nov 06 '17 at 06:15 PM

avatar image

Everynone
15.3k 77 26 64

avatar image emperor_katax Nov 06 '17 at 06:27 PM

.. dude, I reach to other solution ... I will try yours now .... alt text

so no need to put Spawner instance on stage

alt text

... it works smooth ...

22.png (262.3 kB)
24.png (331.5 kB)
avatar image emperor_katax Nov 06 '17 at 07:12 PM

... ha ha ... that was great ! ... many thanks for your attention ... now its pretty works without using events .... it doesn't mean I don't like events, but this way will be less expensive on cpu and user local machine thou ... specially on mobiles ... ; ] ,,, thank you

avatar image Everynone Nov 06 '17 at 07:20 PM

Awesome! Consider marking it as resolved.

(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