|
Storm Game Framework 2.0.0
User guide
|
Build a supply-room door that opens only for a character who owns the supply kit. SGF validates and dispatches the interaction. Your door Blueprint supplies the rule and the visible result.
Complete Equip and show the item. This chapter uses Make Interaction Success and Make Interaction Failure, Blueprint nodes in StormInteraction.
In Project Settings > Gameplay Tags, add Tutorial.Interaction.Failure.KitRequired to a project tag source.
Blueprint's RepNotify setter runs the notification on the server too. Clients receive Open and apply the same rotation. The door's meaning belongs to your game; the interaction component does not define an Open command.
In BP_SupplyDoor, create HasRequiredKit with an Actor input named Interactor and a Boolean output named HasKit. In the function's Details, expand Advanced and enable Const. It reads state and changes nothing; Const also lets the read-only Can Interact interface function call it. A local Found variable is still allowed.
Return false for a missing inventory. Do not read another player's pawn through Get Player Character 0 here: use the Interactor supplied to the function.
Open Can Interact under the Blueprint's interface functions. Call HasRequiredKit with the provided Interactor. Return Make Interaction Success when true; otherwise return Make Interaction Failure with Tutorial.Interaction.Failure.KitRequired. This is a read-only availability query.
Open Interact and repeat the ownership check there. On false, return the same failure without changing Open. On true, set Open to true and return Make Interaction Success. Compile and save.
Checking again in Interact matters: availability may have changed since a prompt was drawn. SGF dispatches the final call on the server, and that call must decide from the server's current inventory. Repeated successful interactions leave the door open.
Open BP_PlayerCharacter and add a Storm Interaction component named Interaction. In its Rules, set Max Range = 300, Require Line Of Sight on and Line Of Sight Channel = Visibility. Keep the character and component replication enabled.
In its Event Graph, add keyboard 5. On Pressed:
The trace is your game's target selection. The server repeats SGF's range and sight checks and gets the interactor from the component's owner. The client sends a target, not a claim that the rule already passed.
Select Interaction and add On Interaction Result. Break its Result and branch on Succeeded. Print Door opened for success. For the kit-required Failure Tag, print You need a supply kit; use Interaction refused for other failures. A failed immediate Request Interact result can also be printed as a submission failure. On a client, a successful submission is not the final door result.
Place BP_SupplyDoor about 200 cm in front of the Player Start, with its actor origin 100 cm above the floor so the panel rests on it. Keep the origin clear of walls: SGF's sight check aims at the actor origin, and putting it at a hinge against a wall or on the floor can produce a blocked-sight refusal. Face the panel and press 5. With the kit, it should open. Stop Play, clear the game mode's Starter Item and temporarily empty the starting loadout. Play again: the door should stay closed and report that the kit is required. Restore the grant and loadout afterwards.
Walk beyond 300 cm or put a blocking wall between character and door: the interaction should refuse. For multiplayer, use two PIE players with a listen server. Check the requesting client's result and both players' view of the door. A newly joined client should see the current Open state; test that separately before shipping.
| Symptom | Check |
|---|---|
| The trace hits nothing. | Face the panel, stay within reach, and check Visibility collision. |
| Every request fails. | Check Max Range, the interface implementation and the component's owner. |
| A client says submitted but the door stays closed. | Read On Interaction Result and its Failure Tag. |
| Only the server sees the door open. | Enable actor replication and apply rotation from OnRep_Open. |
| The no-kit test makes the character unready. | Empty the starting loadout as well as clearing the grant. |
Checkpoint: the server opens the door for a kit owner and refuses without changing it for a character without the kit. Opening does not consume the kit.
Next: Add a screen.