Language:
Page Info
Tags:
Skill Level:
Engine Version:
Share
此中文页面内容对应的英文页面有后续更新,如需浏览最新文档可切换至英文页面浏览。

4 - Setting up and Testing Functionality

本页面的内容:

By now, you've done everything you need to do to have a fully functional vehicle by creating the Wheel, Animation, and Vehicle Blueprints in Unreal Engine 4, except to be able to control it in your game! In this step, we'll show you how to setup the necessary axis mappings and binding so that you can drive the vehicle around and fully test its capabilities.

Because there are a few ways to go about setting up the vehicle for testing and assuming that you did start with a blank project template, all of the inputs will need to be added to control the vehicle. If you started with an existing template, some or all of these axis mappings and bindings may already be available for you in your project.

Setting Up The Controls

  1. Go to the Main Menu and select Edit > Project Settings to open the Project Settings window. Then under the Engine section in the side panel, select Input.

    input.png

  2. In the Bindings, setup the following controls if you do not currently have them listed. If you do have them listed, it would be wise to double-check that they are setup like the ones listed here so that you know your vehicle will work correctly.

    1. Add an Axis Mapping, by clicking the "+" sign next to the Axis Mappings property

    2. Expand the Axis Mappings

    3. Rename the Axis Mapping from "None" to Forward

    4. Click the "+" next to the Forward Axis Mapping

    5. Expand the Forward Axis Mapping

    6. Set the first "None" to "W"

    7. Set the second "None" to "S"

    8. Set the Scale of the "S" mapping to "-1.0"

    9. Add another Axis Mapping, by clicking the "+" sign next to the Axis Mappings property

    10. Rename the new Axis Mapping from "None" to Right

    11. Expand the Right Axis Mapping

    12. Set the first "None" to "D"

    13. Set the second "None" to "A"

    14. Set the Scale of the "A" mapping to "-1.0"

    15. Then add an Action Mapping, by clicking the "+" sign next to the Action Mappings property, for:

    16. Expand the Action Mappings property

    17. Rename the new Action Mapping from "None" to "Handbrake"

    18. Expand the Handbrake Action Mapping

    19. Set the "None" to "Space Bar"

  3. Now that you've got the controls setup, you'll need to actually do something with them. So open up the Vehicle Blueprint that you created in previous step (Step 3) and locate the Event Graph where you'll be able to call theses Axis and Action events that you created in the Project Settins' Input section.

    MyVehicleBP.png

  4. In the Event Graph, for the throttle setup create the following:

    throttleBP.png

  5. In the Event Graph, for steering setup the following:

    steeringBP.png

  6. In the Event Graph, for the handbrake setup the following:

    handbrakeBP.png

End Result

Now with these Input Events added you have a fully functional vehicle that can take input movement! In the next and final step, we'll setup a new Game Mode that uses our Vehicle pawn as the default pawn when we launch a game.

Tags