Portals in your world

A portal of your world is made by an FL# script that runs on the server: NodeWorld has no portal component to drop in the scene. Every player of the room sees it, and goes through it to the world it leads to. Players also drop portals of their own from the menu (Drop portal, explore); this page is about the portals of your world.

A portal always there

A script on the server opens it as the world starts, where its object stands:

csharp
using NodeWorld.Flux;

namespace MyWorld
{
    public class PortalToHome : FluxScript
    {
        public string targetServer = "";       // the id of the server of the target world
        public string targetWorld = "HomeWorld";
        public string label = "";              // empty: the name of the target world

        protected override void Start()
        {
            if (!World.isServer) return;
            Portals.Spawn("home", new PortalOptions
            {
                targetServer = targetServer,
                targetWorld = targetWorld,
                label = label,
                position = transform.position,
                rotation = transform.rotation,
            });
        }
    }
}

Put it on an empty object where the portal stands, with an FL# Script component: the portal takes the object's position and rotation. The portal stays until the room closes or a script closes it (Portals.Despawn).

A portal a player opens

The Portal kiosk of the example world (PortalKiosk.cs) is a button: the player's game sends a network event to the server, whose script opens a portal in front of the kiosk for 30 seconds. Copy it into your world, give its object a Network Id, and set targetServer and targetWorld (portals made by scripts).

Where it leads

PortalOptions
targetServerThe id of the server (a UUID), as the server list gives it: id in GET /servers of the public API.
targetWorldThe World ID of the world on that server.
instanceCodeAn instance of that world; empty: NodeWorld picks one.
labelThe name shown on the portal; empty: the name of the target world.
position, rotationWhere it stands.

Portals.Spawn returns false when the server refuses the portal (an empty target, an id already used in the room). Portals open only on a server: in Play mode, Spawn returns false (limits).