Blueprint children
The goal: a Blueprint whose parent is a Rust class, to assign the assets the class needs (meshes, sounds, input actions, widget classes) and to tune its values, without touching Rust.
This is how every Rusteal template works: the Rust class declares the properties, and a Blueprint child named BP_<Class> fills them in. The game then uses the Blueprint, not the Rust class directly.
Creating the Blueprint
- In the Content Browser, open the folder the Blueprint goes in.
- Right-click an empty area and choose Blueprint Class.
- In the Pick Parent Class window, expand All Classes.
- Type the Rust class’s name in the search box (
Turret). - Select the class in the list and click Select.
- Name the new asset
BP_Turretand press Enter.
Screenshot: the Pick Parent Class window with All Classes expanded and the Rust class found by the search. (images/classes/pick_parent_class.png)
Filling in the properties
- Double-click BP_Turret to open it.
- Click Class Defaults in the toolbar.
- In the Details panel, find the Rust class’s properties under their categories, and set them: pick the sound in Fire Sound, the projectile Blueprint in Projectile Class.
- Click Compile, then Save.
Screenshot: the Class Defaults of BP_Turret with Fire Sound and Projectile Class assigned. (images/classes/class_defaults_assigned.png)
The components the Rust class declares are in the Components panel: select one to give it a mesh or a material.
Using the Blueprint
Place BP_Turret in the level by dragging it from the Content Browser into the viewport, or spawn it from Rust through a SubclassOf<T> property that holds it (see Spawning actors).
Game mode, pawn and controller
A game mode names the pawn and the controller the game uses. With all three in Rust:
- Create a Blueprint child of each:
BP_MyGameMode,BP_MyCharacter,BP_MyPlayerController. - Open BP_MyGameMode, click Class Defaults, and in the Details panel, under Classes, set Default Pawn Class to BP_MyCharacter and Player Controller Class to BP_MyPlayerController. Compile and Save.
- Open the level, and in the World Settings tab (Window > World Settings), set GameMode Override to BP_MyGameMode.
Or, for every level of the project: Edit > Project Settings, Maps & Modes, Default GameMode.
Screenshot: the World Settings tab with GameMode Override set to the game mode Blueprint. (images/classes/world_settings_game_mode.png)
Rules for Blueprint children
- Data, not logic, for what Rust does. A Blueprint child that implements an event the Rust class implements replaces the Rust code for it. Keep the Blueprint’s graph for the
BlueprintImplementableEvents the Rust class declares for it. - Values changed in the Blueprint win. A value set in the Blueprint’s Class Defaults overrides the Rust default. The arrow next to a changed value resets it.
- Hot reload keeps them. When the Rust class changes shape, its Blueprint children move to the new class with their values. See Hot reload.