Tutorials/Building A Minigame Mod

From Pummel Party Mod Documentation
Revision as of 02:57, 16 November 2022 by RBDev (talk | contribs) (Added more content and images about adding item spawner)
Jump to navigation Jump to search

This tutorial will take you through the steps of building a working minigame mode. It will start from a completely empty minigame mod and build up to a working minigame. This tutorial assumes basic understanding of the mod editor, including how to access and create a new mod.

Creating the mod

The mod template being used for this tutorial is the "Empty" minigame mod template. This template has default values for all mod settings and has no gameobjects in the scene. The minigame created is not immediately playable as it lacks spawnpoints and solid ground.

Adding solid ground

Players will need some kind of solid terrain or objects to stand on when they spawn. Their are many props suitable for this. Add a new prop from the hierarchy window by right clicking and choosing 3D Object > Prop. The object you created will be invisible in the scene view as it hasn't got a visible prob assigned to it. With the gameobject selected in the hierarchy, look to the inspector to see the Prop Component attached to the gameobject. Click on the Prop field button in the inspector to assign a new prop. Some good search terms for large terrain-like props are "Ground", "Floor", "Grass", "Terrain" or "Flat". Here I'll choose GroundMounds 05.

ExamplePropInTheScene.png

To make sure players can stand on this prop, check that the Collision Type isn't set to None. It defaults to Mesh, which makes the prop solid in a way that you'd expect, where the collider exactly matches the shape of the visible mesh. For simple props you can use simpler collision shapes, such as the Box or Sphere options.

To quickly build a level for players, duplicate the prop using Ctrl+D and move the copy somewhere else. You can scale, rotate or change the prop each time to add variety to the scene.

SimpleTerrainUsingProps.png

Adding spawn points

A single spawn point set to point mode.
A single spawn point set to circle mode. This can spawn along the edge of a circle.

Now that players have some solid ground to stand on, we need to add spawnpoints to define where they should spawn at the start of the minigame. Add a spawnpoint by right clicking the hierarchy and choosing Minigame Object > Player Spawn. You will see a white pummel party player appear. This indicates a player spawn point.

With just this single spawn point, all 8 players will spawn in the same place. Changing the Spawn Shape to "Line" is better as it will space each player out along a line. You can set the length of this line to space players out further. Alternately, you can use a Spawn Shape of "Circle" to place players in a ring.


If you want finer control over the spawn points of players, the advanced option "Allowed Players" can be used to specify exactly which players are allows to spawn at a specific spawn point. by creating eight spawn points, each only allowing a single player, you can define the exact spawn point for a single player anywhere in the scene. File:EightUniqueSpawnPoints

Make sure all spawn points are above solid ground. It's not very fun for the player who spawns beneath the ground and falls through the level.

Adding a goal or objective

When making a minigame you should decide on what the objective is. For this tutorial the minigame will give players a point whenever they collect an item. We'll start by creating the item. Right click the Hierarchy window and choose Minigame Object > Item This will create a new gameobject that contains an item component. The Item component has many settings and is very versatile. See the Item Component page for an explanation of all of the settings. We just want an item that rewards the player with a point for collecting it. We don't want the player to hold the item so it should be dropped straight away. It should also be destroyed when dropped to make it seem like the player collected it.

  • Under General Settings, set the Item Type to Worn. This is the simplest item type that offers the least functionality. It is all we need.
  • Under Drop Settings, Enable Auto Drop After Time and set it to 0. This will make the item drop instantly on pickup.
  • Under Drop Settings, Enable Disappear when Dropped. This will destroy the item so it can't be picked up again.
  • Under Pickup Settings, edit the 'On Pickup' Actions.
  AddScoreAction.png

Here is what your item should look like in the inspector at this stage.

ItemSettingsModTutorial.png

The last thing this item needs is a prefab containing its visuals. Visuals here just means some objects that can be seen by the players. The item currently has nothing assigned to the Item Prefab field, so it will use the default visual of a carrot. We should provide our own prefab for the item's appearance.

You can create a new prefab in one of a few ways 1. From the toolbar using Assets > Create > Prefab 2. From the asset browser by right clicking and choosing Create > Prefab 3. By dragging a gameobject that you'd like to turn into a prefab, from the Hierarchy Window to the Asset Browser.

I'll use the first option. This creates a new prefab. You can select it and use F2 or Right click > Rename to rename it. I've named the prefab "KeyItemVisuals" because I'm going to make the item look like a key. Double click on the prefab in the Asset Browser to edit it. Add a new gameobject with a prop component to the prefab as a child. You could also add a prop component directly to the root gameobject. Here's how it looks.

KeyPrefab.png

With the prefab created, return to the main scene view by clicking "← Return to Hierarchy" at the top of the hierarchy window. Now select the item and add the prefab you just created to the Item Prefab field. Now in the Scene View the item should appear with the shape of the prefab visuals.

Spawning multiple items

One item is good, but we want players to be collecting many items. We could just duplicate this item and place them around the scene, but what if we want to change the settings on the item? We'd have to go and edit every single item duplicate we made. A better way is to create a prefab containing this item, and make many prefab instances. Then if we want to update something about the item, we can do it in the prefab and all prefab instances in the scene will update.

To create a prefab of the item, we'll use the third method mentioned earlier. Drag the item gameobject into the Asset Browser. This Creates the new prefab, remember to rename it if you'd like. I'll call it "KeyItem". Now you can drag the prefab you just made into the Scene View to add a Prefab Instance to the scene. These appear in blue in the Hierarchy Window. You can also delete the original item gameobject from the scene since it's now stored in the new prefab.

Here I've created eight prefab instances of the KeyItem and am testing the mod in playmode.

KeyItemInPlayMode.png

The keys are a bit small, we can make them larger by editing the prefab they're using for their visuals. Double click on the first prefab we made, "KeyItemVisuals", in the Asset Browser. Scale up the prop. I changed the scale to be 3 on all axis. ScaleToThreeTimesSize.png

Now returning to the hierarchy and entering play mode, the keys look like this.

LargerKeys.png

Much better! Walking into them also collects them and gives a point to the player, so they're working as expected.

Adjusting the Mod Settings

If you have an idea of what the goal of the minigame is, the mod settings can be used to enforce that. See Mod Settings for a detailed explanation of all available settings.

Minigame Details

Here you can set the mod's name as it appears ingame, along with the description and preview shown on the loading screen and in other menus such as the ruleset menu.

To capture a preview image, you can use the screenshot button in the toolbar, or press F10. This will save a screenshot to the mod's Custom assets that will then appear when trying to set a new preview image. You can also import a custom image as an asset through the "Import Asset" button in the Asset Browser Window.

Minigame Controller Settings

Here you can set the win condition and placement rules.

For this tutorial, we'll make the minigame end when someone reaches 10 points. Set the End condition to "Obtain Points" and set the Points to Win to 10. ModSettingsEndConditionExample.png

Minigame Player Settings

Here you can change settings relating to the player , what they can do and what they will see. This includes whether the player is controlled using a third person or top down camera, how fast they move and how high they can jump, if they can punch, if they should use health, and more.

This minigame would be more interesting as a third person style game, rather than a top down minigame. At the top of the Minigame Player settings, change Player Type to "Third Person". This places the camera behind the player and has it follow the player around the level.

Improving the minigame

This should be enough to make our minigame playable. We have a basic scene with collectable items. The items give players points when they're collected, and the player who is the first to 10 points wins. We should make sure there are enough items in the level for all players to win. Remember games can have up to 8 players, so their should be at least 73 items to ensure someone can win even if all items are collected (9 players each and one player collects 10, winning the game).

Respawning items

While the minigame is playable, it's a bit boring and predictable to have items in fixed locations all the time. Players might be able to memorize the most efficient way to get to 10 items and the minigame is not longer challenging or fun. We can use the Prefab Spawner Component to spawn items at many different locations around the level. We can choose ~20 positions to spawn items at, then only have about 5 items spawned at a time. This will force players to run back and forth looking for a new item to collect as they spawn. It also makes the minigame more directly competitive between players; rather than having them all spread out collecting items on their own, they will be more engaged in racing each other to reach the items.

Create a spawner by adding an empty gameobject, then using the inspector to add a Spawner component. This component can be found under Gameplay > Spawner when you click the "Add Component" button in the Inspector Window. We won't be using the position of the spawner to spawn the items so it doesn't matter where you position this gameobject.

Set up the spawner with the following settings.

  • Set the Type to "Spawn On Destruction". This will spawn a instance of a prefab whenever one of the previously spawned instanced is destroyed.
  • Set the spawn count to 5. This is how many prefab instances can be spawned at once.
  • Add the item prefab to the Prefabs list.
  • Set the Locations to just "OnTargets". This will spawn the prefab instances on the given target objects.

Here is how it should look:

KeyItemSpawnerSettings.png

Now we just need to add a set of spawn locations. These are just empty gameobjects that we can place throughout the scene for items to be spawned at. To help visualize these gameobjects you can place a Note Component on them. Here I've spread 18 around the scene.

ItemSpawnpointsSpreadAroundScene.png

The final step once these are placed is to give the spawner component a reference to all of these items. Select the gameobject with the spawner component and expand the Spawn Points list. Add elements for all of the spawn points and one by one fill each element with a reference to spawn point.

PopulatedSpawnPointList.png

Now when playtesting, only five items are present at a time and collecting one will spawn a replacement at one of the spawn points with no item after a short time. This is more engaging and much more frantic to play.