(CF) Game and World Portals

(CF) Game and World Portals
By Mad-Eye#2971 on Discord

This package allows creators to easily add trigger volumes to their games that act either as portals to other games or as portals to other worlds in the same game. When a player steps into the trigger it will display an overlay on the screen with customizable text, an optional thumbnail, and a countdown before teleporting them. The player may leave the trigger volume before the countdown has completed if they don’t want to teleport.

Picture of an overlay

This package is derived from the scripts we use at Charming Forge to take players to our other games and into our houses. The idea behind adding custom spawns to portals between worlds in a game is to allow the construction of detailed, immersive worlds by linking them together in ways that make sense.

For a working example, visit Charming Forge and enter Nya’s house (the one with the large windmill on the roof) through either door. You should spawn near the door you entered. If you leave you will spawn outside the same door. This works for all the developer houses.

Play Charming Forge in Crayta

Don’t hesitate to ask me if you have questions, find a bug, or need help. :slight_smile:

NOTE: The widget in this package allows you to add a thumbnail for your game or world. These must be uploaded as UI images or they won’t work.

DEPENDENCY: This package requires you to add the Local Handler package to your game so the portals can show their overlays to users.

In This Package

Templates

  • Game Portal Trigger: a trigger volume with a script and a widget added.
  • User Spawn Finder: a script folder to add to your User template
  • Custom Exterior Spawn: a locator with a script set for use on exterior worlds
  • Custom Interior Spawn: a locator with a script set for interior worlds

The scripts and UI

gamePortalScript - used on a trigger to teleport players
  • Can be used as a portal to another game or a portal to another world.
  • Contains the font selection for the widget (because dropdown options are not yet supported on widgets)
  • Set the Portal Type property to World and select a world to send players to a different world in your game.

game portal properties

portalOverlayWidget - This is displayed whenever a play stands in a portal trigger.
  • Fonts colours for the game/world name, optional text, and countdown are customizable properties
  • Optionally link an uploaded UI images as a thumbnail.

spawnFinderScript - Used with world portals to spawn users at a designated spawn. (eg. spawning players next to the correct door of a house they entered.)
  • This script finds a locator with a name specified in the gamePortalScript properties and spawns the user there when they teleport to the other world in your game.
  • It can work with the Auto-Respawn package or by itself if you have a blank game.
  • If you’re using the Adventure blueprint you need to modify the adventure script to call this one. Instructions are in the README and in this post.

spawnFinder properties

spawnPropertiesScript - adds options to the custom spawn points
  • These properties allow you to control whether the spawnFinderScript clears the spawn it set for the user.

spawnProperties

gamePortalREADME - a detailed description of this package
  • The readme includes instructions and descriptions similar to this post.

Setup

Game Portals:

These are the simplest to use. You don’t need to use spawn points or modify how players spawn in your game.

Expand Steps
  1. Find the Local Handler package in Community Content and install it. Add the LocalHandler template to your User template.

  2. Drag a gamePortalTrigger into your map where you want the players to stand to teleport. It’s a good idea to add something to the map to make it obvious this is a portal.

  3. The portal type property should already say Game. Change this if it doesn’t.

  4. Fill the game ID property with the ID of the game you want to teleport to. You can get this ID from Crayta’s website. Click “Play” on the website, find the game you want, and copy the code from the end of the address bar. For example, Reef of Riches is 75768228-a1cd-4430-bfd1-fa4a5077358d

  5. Fill any other properties. If you simulate the trigger you can preview the fonts in the editor, like with the Simple Sign package. The You can change the colours and sizes with properties on the widget.

  6. The portal should work now. In the editor it will count down and say “teleport failed” because teleporting while creating isn’t possible. You will have to publish your game to to know if the portal works.

World Portals

The simplest way to use these is to follow the steps above, but set the portal type to World and pick the world you want in the dropdown.

However, the portals have an extra feature: each can be linked to a custom spawn point.
You can use it to make larger games by doing things like placing building interiors on a
separate world to allow more detail and then match the door portals with spawns to make
the world feel more immersive. Try the houses at Charming Forge for an example.

The way this works is through a script added to each user that saves a spawn point name
when the user is sent to a different world. It then finds the matching spawn when the user
arrives in the world.

Expand Steps
  1. Add the userSpawnFinder template from this package to your User template. You don’t need to change any properties.

  2. If your game has no scripts that spawn a player then you don’t have to do anything here.

2a. Alternatives if you have Auto-Respawn or Adventure

This script can work with the Auto-Respawn package if you use that. If you do then find the spawnUserScript on your User template and uncheck Spawn On Login.

OR

If you are using the Adventure blueprint, your player is spawned by AdventureScript. Change the line saying user:SpawnPlayer(nil) to user.spawnFinderScript:FindSpawn() and then uncheck Spawn On Login on the spawnFinderScript on your User template.

  1. Add a gamePortalTrigger to the world your player will start on and change its portal type to World.

  2. The game ID property will be replaced with a World property. Select the world you want from the dropdown.

  3. Set the Spawn Name property to a unique name (eg. spawn_rooftop).

  4. Switch to editing the world you are teleporting to and add a Custom Exterior Spawn or a Custom Interior Spawn. Both templates use the same script, but with different settings on the properties by default.

  5. Rename the spawn point you just placed so it matches the spawn name in the portal exactly. The difference between the two spawn templates is the interior one leaves the saved spawn name in place and also leaves the spawn point saved in the respawn script. If you die after following a portal to one you will respawn at that point. The exterior spawn clears those values so if you die in that world you will respawn at the default spawn.

  6. You can test a world portal in the editor. After you have set one up, preview your game and walk into the portal. When the countdown is done it will say “teleport failed.” Go back to editing mode and switch to the world the portal points to. When you preview this world you should spawn at the spawn point named by the portal if everything is set up correctly.

1 Like