Skip to content
CISV2.0GET IT ON FAB

GUIDESYOUR OWN ACTION

Your own Action

This guide makes BP_MySoundAction, an Action that does what BP_PlaySoundAction does: it plays a sound where the object stands, then finishes. The sound is set per object, so one Action serves every switch. You do it in five steps, with a short graph and no other code.

  • You have followed Quick start, so BP_MySwitch is a switch you can use in the demo map.

Then follow these steps in order.

  1. In the Content Browser, choose Add › Blueprint Class, open All Classes, pick UCISInteractionObjectAction as the parent class and name the Blueprint BP_MySoundAction. An Action has no components, so there is nothing to add.

  2. Open BP_MySoundAction and add the variable. In My Blueprint, click + next to Variables, name it Sound, and set its type to Object Reference with the class Sound Base. Select it and turn on Instance Editable in the Details panel, so the variable shows in the settings of each object that uses the action.

  3. Play the sound. Right-click the Event Graph, choose Add Event › StartInteractionObjectAction, and wire the nodes below. The event runs when the character starts the action on an object. Its parameters are the interaction character, the character’s interaction component, the object’s interaction object component and the side that was used.

    • Add Play Sound at Location from Gameplay Statics. Wire the event’s execution pin to its Execute pin, and the event’s InteractionCharacter to its World Context Object.
    • Drag Sound from My Blueprint into the graph and wire it to the Sound pin of Play Sound at Location.
    • From the event’s InteractionObjectComponent pin, add Get Owner. It returns the object’s actor.
    • Add Get Actor Location and wire the owner to its Target. Wire its location to the Location pin of Play Sound at Location. The location is where the object stands.
    The Event Graph of BP_MySoundAction after step 3. Step 4 adds the last node, Finish Action.
  4. Finish the Action. Wire the Then exit of Play Sound at Location to Finish Action, the function of UCISInteractionObjectAction, as the last node of the graph. Until it runs, the use does not end, and the state of the object does not change. Event OnUseFinished runs when the Action finishes, also when it is interrupted. Use it only for clean-up, such as undoing what the Action started; this sound needs none.

  5. Use it on the switch. Open BP_MySwitch from Quick start. In both entries of its side actions, replace Interaction Object Action BP_PlaySoundAction with BP_MySoundAction. The new Action is a new object, so set its values again in both entries: Sound to S_Switcher_Cue, and New State After Finish Action to CIS.Button.SwitchOn in entry 0 and CIS.Button.SwitchOff in entry 1. Compile and save the Blueprint, then play the demo map.

The table lists the settings of the Class Defaults of BP_MySoundAction, shown below.

Default
SoundNone
Settings
New State After Finish Action
Execution
Instancing PolicyDefault
Net Execution PolicyAll Machines
The class defaults of BP_MySoundAction.
SettingWhat it does
Net Execution PolicyWhere the Action runs in a networked game. All Machines plays the sound on every machine, so every player hears it.
Instancing PolicyHow the Action is copied. The default, Default, makes a separate copy for each use of a Blueprint Action, so one use does not change the next.
Set New State After Finish ActionWhether the object takes a new state when the Action finishes. It is on by default.
New State After Finish ActionThe state the object takes when the Action finishes, if the setting above is on. Set it on each entry of the switch’s side actions, as in step 5.
  • Walk up to the switch and press E: the click plays at the switch, and the switch changes state.
  • The switch changes state when Finish Action runs, which is right after the sound starts. The sound itself is not waited for.
The switch seen from the demo character's view, with the E | INTERACT prompt above it.
The switch from the character's view: the prompt shows it can be used.
  • The use never ends: the graph has no Finish Action call, or it is not reached from Play Sound at Location. Add it as in step 4.
  • There is no sound: Sound is not set in the entries of BP_MySwitch (step 5). The variable must be set on the object, not only in BP_MySoundAction.
  • Only one player hears the sound: check Net Execution Policy in the class defaults. All Machines plays it on every machine.