Spawning NPC units on server from client widget in LYRA

Hi,

I’m trying to develop a system where players can create new unit NPCs, using the Lyra game framework. This is using the dedicated server model. The NPC units are similar in nature to those from an RTS - Different classes of units players can create, units are on the same team as the player but not considered players themselves.

I’m unable to use the included LyraBotCreationComponent, as that system creates player bots, spawning them using GameMode->RestartPlayer(NewController).

I’ve created a widget that pops up and allows the player to select which units to spawn. That much, at least, works. Widget appears, buttons are interactable.

Where I’m having difficulty is in getting the command to spawn the unit to the server.

What almost works is creating a simple Game State Component, adding it to the experience like this, and calling it from the widget like this. It actually works perfectly! Problem is, this solution only works in Standalone or Listen Server mode. Calling it as a client results in:

LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor LyraGameState_0. Function OrderUnit will not be processed.

I’ve tried routing the request through the player controller instead, however that results in an invalid spawn request that kicks me out of the game back to the main menu.

I have a feeling the ideal solution may lie within Lyra’s subsystems, but I’m just not familiar enough with them to see it. Can anyone help?

On press : you need to have the local client call an RPC event on the server. Your server proxy (authoritative) then runs all the code.

The Server owns NPC’s.