6. Launch Your Character


Our launchpad is going to work by using a function called Launch Character. The Launch Character function adds the velocity you specify to the Character's current velocity, allowing you to throw it in whichever direction you would like. It only works on Characters, though, so we need to make sure that our Pawn (avatar) is a Character (humanoid avatar).

We do this by casting. Casting attempts to convert your input into a different type, so you can access specific functionality that is only allowed for that particular type. It will succeed if your input is based on that type.

Everything you can place in your level is an Actor, in addition to any other specialized behavior added on later. That means that you can get a reference to anything in your level, cast it to Actor, and it will succeed. However, not everything in your level is the Pawn representing you in the game, so casting something to Pawn may or may not succeed.

  1. Drag off of the Return Value pin of Get Player Pawn.

  2. Type "Cast" into the search box, then select Cast to Character in the context menu.

    CasttoCharacterMenu.png

  3. Drag off of As Character pin on the Cast node.

  4. Type "Launch" into the search box, then select Launch Character in the context menu.

    LaunchWired.png

    Notice that the output execution pin for successfully casting automatically connected to the input execution pin of Launch Character.

  5. Type "3000" into the Z field of the Launch Character node.

  6. Finally, wire up the True execution pin of the Branch node to the Cast to Character node's input execution pin, so the Cast to Character and Launch Character only occur if the overlapping Actor is our Pawn.

    GraphDone.png

    At this point, Compile and Save the Blueprint using the toolbar buttons, then close the Blueprint Editor.

  7. Drag several of the launchpads into your level from the Content Browser.

    MultipleLaunchpads.png

  8. Click on Play in the toolbar, then run around the level (with WASD) and jump (with Spacebar). Land on one of the platforms and watch as you go flying through the air!


Tags