Announcement

Collapse
No announcement yet.

Communicating between separate blueprints

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Communicating between separate blueprints

    Hi everyone,

    I'm new to the blueprinting system and I'm running into confusion left, right and center, however I know making mistakes and experimenting is necessary! I've followed a few tutorials to get me going and I'm concurrently building a project pertaining to my university course, which contains an object inspection mechanic inside of the 'FirstPersonCharacter' blueprint, and a seperate blueprint holding a spotlight which loops visibility on a timer in the event graph...the question is, how do I get the spotlight to temporarily stay visible every time the inspection mechanic is active (the sequence of the player inspecting)?

    Click image for larger version

Name:	2017-03-31 (1).png
Views:	1
Size:	480.2 KB
ID:	1215860

    Here is the blueprint for the inspection

    Click image for larger version

Name:	2017-03-31 (3).png
Views:	1
Size:	280.6 KB
ID:	1215861

    The spotlight behavior logic

    #2
    You can call events, modify variables, and modify properties from the Cast To node. For example, you could drag off of the actor reference pin and you'll notice that the options that come up pertain specifically to that casted object. To modify the visibility of an object, drag off from the Cast To node and type "set visibility".

    Comment


      #3
      The problem is that I'm casting to the Spotlight_BP and my cast node requires the spotlight component reference to plug into the 'object' pin :/

      Click image for larger version

Name:	2017-04-06 (1).png
Views:	1
Size:	394.0 KB
ID:	1126051

      Comment


        #4
        If it's a component in the actor you can drag off its reference to activate and deactivate.
        Inphidel / Brian - Developer of Ultraball
        http://www.ultraballgame.com

        Don't shy away from bugs in your game. Don't play it as intended. Break your game so you can fix it!

        Comment


          #5
          Hardcoded references between isolated blueprints is almost always a bad idea.
          Interfaces and event dispatchers are most of the time a better communication mechanism.
          | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

          Comment


            #6
            The "Object" slot needs a specific instance of your spotlight blueprint.

            For example, I might have a blueprint called "car_bp". I can put several of those "car_bp"s in my level. Without referencing which one in particular you want to cast to, the cast doesn't know which instance it's meant to affect.

            There are several ways to get a reference to the exact object. If there's only one "spotlight_bp" in your level you could use the "get all actors of class" node, set the class to "spotlight_bp", then drag a "get" node from the array and plug it into the object slot.

            If there are more spotlights and you only want to affect one, look up how to reference specific actors. There are a ton of ways.

            tldr; a cast needs an object that exists in the game world. It will affect that object only.

            Comment


              #7
              There's a video explaining blueprint communication: https://www.youtube.com/watch?v=EM_HYqQdToE

              In your case you can set up an event dispatcher in your character BP and call it in your Inspection event, then assign the event dispatcher in the Spotlight BP. The only thing you need in your Spotlight BP is a reference to the sending object (your character), which is easy in case you're controlling that character. You can Get Player Controller - Get Controlled Pawn - Cast as YourCharacterBP with a pure cast (right click the cast node and convert to pure cast).

              For the logic you can create a boolean input in the event dispatcher and use that for controlling whether you're inspecting or not. So when you first start inspecting you call the dispatcher with Inspecting = true, then when you're done inspecting call the dispatcher with Inspecting = false, and just set up a branch in the Spotlight BP.

              Comment

              Working...
              X