5. Test the Overlapping Actor


Right now, that OnComponentBeginOverlap event will execute when anything overlaps the Box trigger. We only want to actually execute our launching behavior, though, if the overlapping thing is our avatar, or Pawn. Think of it as asking "Is the Actor overlapping the Box trigger the same Actor as our Pawn?"

We will do that by working with the Other Actor output from the OnComponentBeginOverlap event.

  1. Click on the Other Actor pin on the OnComponentBeginOverlap event, and drag into an empty spot on the graph and release to pull up the context menu.

    OtherActorContext.png

    The context menu is adaptive, filtering by the pin you are currently working with to show you only nodes that are compatible.

  2. Type "=" into the search box to filter the available nodes, then select Equals (Object).

    EqualsOtherActor.png

    We could set Side Scroller Char as the other input to the Equals node, but then if we changed the Character we were using, we would need to re-open this Blueprint and manually update that. Instead, lets get a reference to the current Pawn we are using.

  3. Right-click in an empty part of the graph to bring up the context menu.

  4. Type "Pawn" in the menu's search box, then select Get Player Pawn (under Game).

    GetPlayerPawnMenu.png

  5. Connect the Return Value output on Get Player Pawn to the second input on the Equals node.

    EqualsComplete.png

    Now that we have got a node that will tell us if the Other Actor is the Pawn our player controls, we will use the answer to change the execution flow of our graph. That is, we will direct the execution flow as it leaves the On Component Begin Overlap node.

    For that, we want to use a Flow Control node, specifically the Branch node.

  6. Drag off of the execution pin on the OnComponentBeginOverlap node and release in an empty part of the graph.

    ExecutionMenu.png

  7. Type "Branch" in the search, then select Branch from the context menu.

    BranchAdded.png

  8. Connect the output pin of the Equals node to the input Boolean pin on the Condition node.

    BranchComplete.png

The graph is now ready for you to set up different behavior to execute depending on whether the overlapping Actor is your Pawn or not. In the next step, we will do just that, and set up Blueprint nodes to launch our Character if the result of the Equals comparison is True.


Tags