Skip to content

Ghost Tutorial: Building a level

Jasdac edited this page Dec 18, 2024 · 8 revisions

Building the level

Note that currently the navmesh markers need to be linked to the root prim. Try to fit all the doors within a 40x40x40m area, and try to stick to a single linkset if possible (max 256 links).

Your level should have an "anchor". A prim underneath the level that acts as a root prim.

Set the object description of your level to LEVEL. Only objects that have a root prim with a LEVEL description will allow players to drop items on it.

Setting up EEP & Soundspace

You can setup environment, soundspace, and footsteps by editing the prims that players walk on and changing their description, no code is needed. xMod uses exactly the same syntax as GoThongs, tasks being an array separated from their args by $ and separated from other tasks with $$. Ex: task0$arg0$arg1...$$task1$arg0$arg1...

  • Soundspace is setup by task SS$<uuid/label>$volume, Ex: SS$ru$0.1 - See Soundspace.lsh for a list of built in sounds. Soundspace persists until the user walks over another prim with a soundspace. So it's recommended to set it on prims players walk on as they enter/exit a new soundspace area, such as one on the ground outside of the house, and one inside the entrance.
  • Footsteps are setup by task tFS$, Ex: tFS$SNW. You can see a list of built in sounds in Footsteps.lsh. Every prim that users are expected to walk on needs a footstep setting, so it's best to set these on the prims before placing them.
  • Environment is setup by task WL$ and accepts a uuid for an EEP sky setting. Ex: WL$b1feea57-fed9-e7d9-d90e-c08adfdd9d33. Just like soundspace, environment persists until the user walks over a prim with a different sound setting.

A full example of a map floor setting: tFS$SNW$$WL$b1feea57-fed9-e7d9-d90e-c08adfdd9d33$$SS$ru$0.2

Placing the start point

The dev kit comes with the truck used in most phasmo levels. The truck isn't needed, but the scripts and assets in the monitor are. The monitor contains all the scripts and assets used in the level. Note that most of the assets used in the level are updated from the HUD, meaning you can't customize them unless you change their name.

Take a backup of your level, then link the start point to the level. But note that you'll need to re-fetch the scripts before testing anything.

Preparing rooms in the script templates

  1. Edit the #Nodes script.
  2. Edit the ROOMS list. The ROOMS list has a stride of 3: [(str)shortName, (str)fullName, (int)flags]. Currently the only flag used is ROOM_PLUMBED and is used for the Gooryo to teleport between plumbed rooms.
  3. Come up with short names, full names, and flags for each room that you want the ghost to be able to visit. Don't add any areas outside of the ghost's play area, such as outdoors in a house if you only intend for the ghost to be indoors.

We will be referring to the nodes list a lot in coming steps. When you compile, the script will probably complain about missing room markers. So we'll add those next.

Setting up the navmesh

Navigation for the ghost is very simple. You use a prim (any prim will do, I use a default cube) where the X axis goes between rooms. No scripts are needed, we use the description.

  1. Create a prim, such as a cube. Name it PORTAL. I usually make the face in the positive X direction red.
  2. Position it in a doorway.
  3. Set the description to <FROMROOM_SHORTNAME>:<TOROOM_SHORTNAME> where negative X is pointing towards FROMROOM and positive is pointing towards TOROOM.
  4. Link your portal object to the map and change its physics shape type to NONE, and then make it transparent.
  5. Repeat for all doorways. Note that the ghost will try to go 1m behind/in front of the marker when it goes between rooms. For some types of stairs to work, you may want to add the stair as a separate "room". Experiment with it. The ghost won't get stuck when moving between rooms, but it may teleport through walls if you don't set this up correctly.

Setting up room markers

Room markers are used to tell the game which area is which room, and uses boxes to mark these.

  1. Drag a ROOMMARKER object out from the monitor in the truck.
  2. Resize it to fill an entire room
  3. Touch it to store the scale in the description.
  4. Edit the marker and change the second entry to the short name of the room.
  5. Say SAVE rooms to save it. If you mess up or want to change something, refer to the commands on the wiki index page.
  6. Repeat this process for all the rooms that the ghost should be able to visit. Ghosts will never enter an area that isn't inside a room marker. Room markers may overlap slightly. A room can use multiple room markers as long as they all use the same shortname (if the room isn't box shaped for an example).

Setting up the player start position

  1. Edit the #AUX script.
  2. Go to the pos where you expect players to start.
  3. Say POS to get your player position relative to the level.
  4. Paste the vector into the START_POS define.

Adding ghost spawn locations

  1. Edit the #AUX script.
  2. Do the same procedure as before, going to the places where the ghost should spawn and say POS to get your player position.
  3. Paste them into the GHOST_SPAWNS list.