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"

Passing values from class BP to level BP through events

I have a class BP (Glow_Boxes - a simple box mesh) which contains logic to toggle whether the box glows or not. Shooting the box will cause it and surrounding boxes to toggle their glow. The method I am aiming for is:

  1. The player shoots one of any meshes of type Glow_Boxes.

  2. That Glow_Boxes mesh's hit event is activated, which causes it to pass some values to the level BP (for example, ID name)

  3. The level BP receives the values and now knows which Glow_Boxes mesh was hit, then does some logic to find any other nearby Glow_Boxes.

  4. The level BP then tells the hit Glow_Boxes instance and all other nearby instances to all toggle their glow.

Steps 3 and 4 are relatively easy by creating an array of Glow_Boxes within the area and then calling a custom event on them through a foreach loop. The difficulty I am having is passing information from the class BP to the level BP, specifically having an event in the level BP triggered through a class BP.

Is it possible to have an event in the level BP that is activated by one of any instances of a class BP? And then to allow the level BP to find out which instance called it?

One method I guess is to manually bind events in the level BP to every Glow_Boxes instance, but that only seems practical with a small number of meshes.

Thanks for any advice.

Product Version: Not Selected
Tags:
more ▼

asked Aug 31 '14 at 04:39 PM in Blueprint Scripting

avatar image

tokyogreg
1 1

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

1 answer: sort voted first

The way that I solved this problem was to create a collection and a collection manager in my GameState blueprint. I prefer to put level code there because it promotes re-usability across the full game and prevents me from doing smarmy things like trying to adjust the state of my systems over time inside of a "state-only" construct.

I created a Blueprint Interface for "GamePhase" listening (GamePhaseListener_INTERFACE) classes. Each of the objects that want to respond to changes to game phase implement this interface. When each object that will want to listen to gamephase changes is instantiated it registers with my GameState by adding itself to a list of actors (that ostensibly implement the interface) and whenever a change is made to the game phase (through a function on the game state blueprint) a message is "broadcast" to all implementing actors in that collection.

Doing it this way, rather than having peer-to-peer style event broadcasts easily prevents me from inadvertantly re-messaging a single message to any individual actor more than once. Recursion can be a real problem with blueprints because there is a total limit on the number of messages you can send in a single tick. In my case I also put some distance checking code on the listeners to see whether or not they even care about the event that was posted (which might be useful in your case.)

The GamePhaseChanged message that gets emitted includes the original actor that spawned the event, the position of the event instigator (if it was the player that triggered something but another object actually kicked off the event) and a collection of all objects that have so far responded to the event. (This allows me to pear down the list of potential responders as the event ages out in the system.)

more ▼

answered Aug 31 '14 at 05:08 PM

avatar image

Thomas Ingham
326 16 24 34

(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