This page lists a few 'recipes' that will teach you in a few steps how to do common tasks.

Introduction

Want to get started quickly with the Corgi Engine? This page contains simple steps you can follow for a number of basic situations, no explanations, just quick steps. Don’t hesitate to check the rest of the documentation to learn more about how the engine works! Note that most of these will provide Corgi Engine / Unity versions, that’s just to provide the context they were first written in. But it’s safe to assume that they should work on any higher versions of both Unity and Corgi Engine.

Creating a simple playable character and setting it in a scene

Creating a simple character :

  • in Unity 2019.4.28f1, import Corgi Engine v7.2.1
  • open the MinimalLevel demo scene
  • create an empty game object, position it at -10,-3,0, name it MyTestCharacter
  • create a new empty child game object to the MyTestCharacter node, add a SpriteRenderer to it, set its Sprite to Adventurer_0, name it MyModel
  • on the MyTestCharacter node, add a Character component, press the AutoBuildPlayerCharacter button at the bottom of it
  • drag your MyModel into the Character’s inspector’s CharacterModel field
  • edit the BoxCollider2D’s size to 0.8,0.8

Setting it as the playable character in our scene :

  • drag the MyTestCharacter node into your project to make it a prefab, then remove it from the scene
  • select the LevelManager, and drag your newly created prefab into its PlayerPrefabs[0] slot
  • press play, enjoy your newly created character
  • make sure you read the rest of the documentation to learn more about how to create more complex characters

Creating a ladder

  • in Unity 2019.4.24f1, create a new project
  • import Corgi Engine v6.7
  • open the MinimalLevel demo scene
  • create a new empty game object, call it “TestLadder”
  • add a sprite renderer to it, in its sprite slot select blocks_25
  • add a box collider 2D to it, set it to trigger, change its size to 0.3, 5
  • change the object’s layer to Ladders
  • add a Ladder script to it
  • press play, you’ve got a ladder
  • you can go further by adding a ladder platform to it, you can see how it’s done in the Minimal’s Ladder prefab

Creating a jumper moving platform

  • in a fresh install of Unity 2019.4.18f1, import Corgi Engine v6.7
  • open the FeaturesPlatforms demo scene
  • drag a MovingPlatform prefab in the scene, at -72,-2,0
  • create an empty game object, nest it under it, call it Jumper
  • add a jumper script to it, set its JumpPlatformBoost to 5
  • add a BoxCollider2D, set it to trigger, and its size to 5,1
  • press play, enjoy

Adding a repositionable mobile joystick in place of the regular one

  • create a new project in Unity 2019.4.26f1
  • import Corgi Engine v7.0
  • open the demo located at CorgiEngine/ThirdParty/MoreMountains/MMTools/Tools/MMControls/Demo, select its JoystickRepositionable node, copy it
  • open the MinimalLevel demo scene
  • open its UICamera prefab
  • paste the repositionable joystick under Canvas and next to the existing Joystick node
  • position it at 400,-1000
  • disable it
  • in its MMTouchRepositionableJoystick’s inspector, drag the UICamera node into its JoystickValue slot. Select the InputManager.SetMovement method (the one at the top, under DynamicVector2, NOT the static one)
  • drag the UICamera into its TargetCamera slot
  • select the UICamera’s top level, and drag the JoystickRepositionable node into the GUIManager’s inspector’s Joystick slot
  • save your prefab, exit prefab mode
  • select your UICamera, and on the InputManager inspector, set ForcedMode to Mobile, and MovementControl to Joystick press play, enjoy your repositionable joystick

Setting up an enemy so that it respawns after the Player character dies

  • in a new project in Unity 2019.4.26f1, import Corgi Engine v7.1.
  • open the MinimalLevel demo scene
  • drag a Bear3D prefab into the scene, position it at -11,-4,0
  • drag a Urchin prefab into the scene, position it at 5,-2,0
  • select the Bear3D, add a AutoRespawn component to it
  • press play, jump on the bear to kill it, then move right and jump on the urchin to die
  • after the respawn delay, the player respawns, and so does the bear

Starting a level with weapons pre-added to an inventory

  • fresh install of Corgi Engine v7.2.1 on Unity 2019.4.28f1
  • open the FeaturesWeapons demo scene
  • select the RectangleWithInventory prefab in your project view
  • under CharacterInventory, set the AutoAddItemsMainInventory array size to 1, drag the InventoryMachineGun asset into the Item slot, set quantity to 1
  • Drag the InventoryGrenadeLauncher asset into the AutoEquipWeapon slot
  • press play, you now start with the grenade launcher equipped. Press T to switch to the machine gun, press T again to revert to the grenade launcher

Using the new input system in other scenes :

  • fresh install of Unity 2019.4.19f1
  • import Corgi Engine v6.7
  • install Input System v1.0.2
  • open the MinimalLevel_InputSystem demo scene
  • copy the UICamera_InputSystem node
  • open the Lava demo scene
  • paste your node in the hierarchy panel
  • remove the UICamera node
  • press play, you’re now using the new input system

Adding a level to RetroAdventure

  • create a new project in Unity 2019.4.22f1
  • import Corgi Engine v6.7
  • duplicate RetroAdventure3, name it RetroAdventure6
  • add that newly created scene to the build settings
  • open RetroAdventureLevelSelection, under the Content node, duplicate the RetroAdventureLevel5 node, change its ItemTitle’s text to “Level6”, on its RetroAdventureLevel comp, change scene name to “RetroAdventure6”
  • on the RetroAdventureProgressManager (in that scene and on the prefab), add a 6th scene, set its name to “RetroAdventure6”
  • press play, go through the levels
  • at the end of lvl 5 you get redirected to the level selection (that’s normal, we didn’t change the exit scene in that level)
  • play level 6, collect some stars in it, return to level selection, enjoy your newly collected stars

Setting up a simple room

  • in a fresh install of Corgi Engine v7.2.1 on Unity 2019.4.29f1
  • open the MinimalLevel demo scene
  • create a new empty game object, name it Room1, position it at -9.5,0,0
  • add a BoxCollider2D to it, set its size to 20,11, then add a Room component to it, set its layer to IgnoreRaycast
  • add an empty child object to it, name it Confiner, add a CompositeCollider2D to it, geometry type: polygons, then copy and paste the Room’s BoxCollider2D on its child, and check UsedByComposite on it, on the Rigidbody set Body Type to static
  • add another child to Room1, name it VCam, add a CinemachineVirtualCamera to it, and a CinemachineCameraController to it, uncheck ConfineCameraToLevelBounds on it
  • on the CinemachineVirtualCamera, set ortho size to 3, and Body to Framing Transposer, then add a CinemachineConfiner, in Confine Mode : Confine2D, and drag the Confiner object into its BoundingShape2D slot
  • on the Room1 object, drag the VCam object into the Virtual Camera slot and the CinemachineCameraConfiner slots
  • open a new inspector for the Confiner object, lock it, and drag the BoxCollider2D from that inspector into the Room’s Confiner slot

Recreating a RetroAdventure-like progress

Creating new scenes

  • in a fresh install of Corgi Engine v7.2.1, in Unity 2019.4.28f1
  • duplicate the MinimalLevel, name it Progress1
  • open it
  • select the RetroAdventureProgressManager prefab, change its 5 scene names to Progress1, Progress2, Progress3, Progress4 and Progress5
  • drag the prefab in your scene
  • drag a RetroAdventureLevelEnd prefab in your scene, position it at -4,-4.35,0
  • change its FinishLevel/LevelName to Progress2
  • select the ButtonLevelSelection’s Background, set its LevelSelector’s Level Name to RetroAdventureLevelSelection
  • remove the UICamera from the scene, drag a RetroAdventureUICamera into it instead
  • disable its InventoryCanvas child
  • save the scene
  • duplicate it, rename the copies Progress2, Progress3, Progress4 and Progress5
  • open them each to edit their RetroAdventureLevelEnd and change the destination scenes to n+1, have Progress5’s be RetroAdventureLevelSelection
  • add all 5 levels to the build settings (file > build settings > drag and drop your new scenes in the list)

Creating a new level selection scene

  • duplicate the RetroAdventureLevelSelection scene, name it ProgressLevelSelection
  • for each of the buttons (at the RetroAdventureLevel component level), change the Scene Names to Progress1, 2 etc
  • save the scene
  • add it to the build settings

Testing

  • click the “Tools > More Mountains > Reset all progress” menu item
  • press play, notice all levels are locked except level 1
  • click on level 1’s play button
  • in Progress1, move right to touch the level’s exit
  • click on the “next level” button
  • in Progress2, move right to touch the level’s exit
  • click on the “next level” button
  • in Progress3, press escape, then Back to level selection
  • notice all 3 first levels are unlocked