Improbable Icon

Physics Only Entities in Unreal SDK


#1

When building an entity, e.g. in the entity templates in Gamelogic/EntityTemplates/EntityTemplateFactory.cs, specify PhysicsOnly for those components that should only be editable by server-side workers. Otherwise, you probably want to use SpecificClientOnly(clientId) to restrict editing to the client that “owns” the entity. Read the ”Access control lists” guide for more information.

public static Entity CreatePlayerCreatorTemplate()
{
    var playerCreatorEntityTemplate = EntityBuilder.Begin()
        .AddPositionComponent(Improbable.Coordinates.ZERO.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
        [...]
        .AddComponent(new PlayerInput.Data(new Joystick(0, 0)), CommonRequirementSets.SpecificClientOnly(clientId))
    [...]
}

Where can I find similar function or definition for CommonRequirementSets in Unreal SDK?

Thanks


#2

Hi @pn.ghodasara

Hope all is well. In the Unreal SDK we don’t have an equivalent of the CommonRequirementsSets provided by default. Instead you have to provide your own requirements sets. In the section Creating an entry there is an example of how it is done and how it is used with the entity builder.

Hope this helps,
Daniel


#3

Hi @danielhall
I figured that commonrequirementsets is not defined in unrealSDK. But it is still widely used in Unreal Documents. Even the page that you linked step 3, which explains the write access uses it.

Anyways, since I don’t have any specialised physics workers, giving write access to unrealworkerwritepermission should make server authoritative for that entity component, right?

So if I created an entity higher than floor level, then on the server it should technically drop to the floor just using physics and on the client I can replicate the server, right?

Thanks


#4

Hi @pn.ghodasara

THe unrealWorkerWritePermission is defined in this section https://github.com/spatialos/UnrealSDK/blob/master/docs/interact-with-world/create-delete-entities.md#1-create-an-entity-template and used throught the document. you would have to do the same definition in your project to make it available for use. The examples allow the UnrealWorkers to have authority on in the entities that use that worker requirements set.

The entity on the server worker(UnrealWorker) would update the physics and then you would have to update the components for your entitys position to reflect that using the SpatialOSComponentUpdater.

Hope this helps:)

Daniel