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

How to import the Corgi Engine in your project?

  1. Create a new project from Unity Hub, pick the latest stable version of Unity as your Unity version, and 2D or 3D as the Template
  2. Go to the Asset Store window and import the project (it has to be in an empty project, not an existing one)
  3. You will be warned that importing the Corgi Engine will overwrite your current project settings (that’s normal), click on Import.
  4. This will take a bit of time.
  5. Once this is complete, you’ll get a prompt saying “This Unity Package has Package Manager dependencies”. This is also normal, click on “Install/Upgrade”.
  6. After that you’ll get a list of the contents of the engine, don’t touch anything, and click on Import in the bottom right corner.
  7. Import will also take a while. Once import is complete, you’re ready to use the engine. Have fun!

How to import the Corgi Engine in a URP project?

The engine doesn’t do any rendering, it’ll work with any render pipeline.

The demos are made using the Standard Render Pipeline, as it’s still the only stable one, and the most common denominator, but you can use any RP you prefer. If you decide to use URP or HDRP in your project, the best approach would be to keep another project at hand, using SRP, to test the engine’s demos in, while you implement your own game in URP/HDRP.

Below are steps to install the Corgi Engine on a URP project. It’s recommended to have at least basic knowledge of render pipelines before picking URP or HDRP, considering the many quirks of these two render pipelines.

  1. Create a new project in Unity 2019.4.28f1 (or higher), using the URP template
  2. Import the Corgi Engine from the Package Manager
  3. Open the MinimalLevel demo scene (or any scene)
  4. Open your project settings (Edit > Project Settings), in Graphics, at the top of it, set a Scriptable render pipeline asset (the URP default template usually comes with a few, pick the HighQuality one)
  5. In the scene, select the UICamera, on its Camera component, set RenderType to Overlay
  6. Select the MainCamera (called Regular Camera in some scenes), at the bottom of its Camera component, add the UICamera to its Stack
  7. If you want to convert all (or most) materials to URP, simply go to Edit > Render Pipeline > Universal Render Pipeline > Upgrade Project Materials to URP Materials, press play, the demo will play. Note that you’d also have to port post processing effects, as Unity went with a different system (volumes) on URP/HDRP.

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

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

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 moving platform

  • Start by dragging a sprite in your scene, or a 3D model
  • Select your newly created game object, and set its layer to “MovingPlatforms”
  • Add a non trigger BoxCollider2D to it
  • Add a Rigidbody2D component to it
  • Add a MovingPlatform component to your object.
  • You’re done! All that’s left to do is tweaking the MovingPlatform’s component’s inspector.

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

Adding a checkpoint to a scene

  • fresh install of Corgi Engine v7.5.1 on Unity 2019.4.34f1
  • open the RetroAI demo scene
  • create a new empty GameObject, name it MyCheckpoint, position it at -63,-5,0
  • add a BoxCollider2D to it, set its size to 1,10, isTrigger:true, and add a Checkpoint component to it
  • press play, walk right under the red platform, go through the checkpoint and die on the spikes, you’ll respawn at the checkpoint

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

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

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

Setting up simple rooms

Setting up a first 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 (Add extension dropdown at the bottom of the virtual camera’s inspector), 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

Creating a second room

  • select Room1, duplicate it, name it Room2, position it at 10.5,0,0
  • on Room2’s vCam, set its CinemachineVirtualCamera’s Priority to 0
  • select the left wall of the MinimalLevel (named “Platform100x1000 (6)”), duplicate it, move it to 0,0,0 to create a wall between the 2 rooms

Linking both rooms with teleporters

  • create a new empty child under Room1, name it Teleporter1, add a SpriteRenderer to it, set its Sprite to AchievementIcons_6 (a simple yellow circle)
  • set its layer to Default, under the Rooms foldout, set CameraMode:CinemachinePriority
  • position it at 8,-4,0, add a BoxCollider2D to it, isTrigger:true, add a Teleporter component to it
  • duplicate the Teleporter object, name it Teleporter2, parent it to Room2, position it at -9,-4,0, change its SpriteRenderer color to black
  • on Teleporter1, under the Destination foldout, drag Teleporter2 into the Destination slot
  • still on Teleporter1, under the Rooms foldout, drag Room1 into the CurrentRoom slot, and Room2 under TargetRoom
  • on Teleporter2, under the Destination foldout, drag Teleporter1 into the Destination slot
  • still on Teleporter1, under the Rooms foldout, drag Room2 into the CurrentRoom slot, and Room1 under TargetRoom
  • press play, move right, once you connect with the yellow teleporter press space to get to the other room

Setting up simple Cinemachine Zones

  • In this example we’ll work in MinimalCinemachineZones, and for that we’ll disable all existing CinemachineZones. Feel free to adapt sizes and positions to your own context.
  • Create a new empty gameobject, name it MyZone, position it at -71,-2.5,0
  • Add a BoxCollider2D to it, set its size to 31,11.5
  • Add a CorgiCinemachineZone component to it
  • Create an empty child object, name it VirtualCamera
  • Find a virtual camera you like. We’ll use the one under MinimalCameraRig, right click on the CinemachineVirtualCamera component, copy component, and then “paste component as new” on our empty VirtualCamera object
  • At the MyZone level, drag the new VirtualCamera into the VirtualCamera slot. As this is our first zone in our level, we’ll also check CameraStartsActive. We want the Player to activate this zone, so we’ll select the Player layer in the Trigger Mask dropdown, and we’ll check SetupConfinerOnStart to let the engine handle all the complex confiner setup.
  • Press play, your camera will now be confined to that zone.
  • Exit play mode, and duplicate MyZone into a new MySecondZone object. Move it to -40,-2.5,0
  • Notice at the bottom of the inspector you can change the zone’s gizmo color, pick one you like
  • Select the second zone’s virtual camera, and under Lens, set the OrthoSize to 3
  • Press play, move right, you’ll transition to the new zone, with a more zoomed in camera
  • You can now add more zones to cover your whole level, position them however you like
  • If you want to tweak camera transitions between zones, that’ll be on the CinemachineBrain on your camera (in this case the Regular Camera object under MinimalCameraRig). You’ll want to change the DefaultBlend and its associated duration.

Setting up points of entry to go to a specifc point in another scene

  • in a fresh install of Corgi Engine v7.5.1 on Unity 2019.4.37f1
  • duplicate the MinimalLevel demo scene twice, name the new scenes SceneA and SceneB
  • add them to your build settings (edit > build settings, then drag both SceneA and SceneB into the “scenes in build” panel)
  • open SceneB, add a new, empty game object at 0,-3,0, name it Entry0, add another at 15,-3,0, name it Entry1
  • select the LevelManager, and add both Entry0 and Entry1 to its PointsOfEntry list, save the scene, make sure you set the DebugSpawn to null
  • in SceneA, create a new sprite, set its sprite to AchievementsIcons_6 (or any sprite of your choice), position it at -5,-4,0
  • add a BoxCollider2D to it, isTrigger:true
  • add a GoToLevelEntryPoint component to it, under ActivationConditions, set AutoActivation:true, under Finish Level, set LevelName to SceneB, save the scene
  • press play, walk right to collide with the sprite, sceneB will load and you’ll spawn where you positioned the first entry point
  • exit play mode, select your GoToLevelEntryPoint, set PointsOfEntryIndex to 1, press play, walk to it, sceneB will load and you’ll spawn where you positioned the second entry point

Creating a very simple AI character

  • in Unity 2019.4.36f1, import Corgi Engine v7.5.1
  • open the MinimalLevel demo scene
  • from the project panel, drag a Platform1000x100 prefab into the scene, position it at 0,-1,0
  • create an empty game object, position it at 0,0,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 AutoBuild AI Character 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
  • on the AI’s AIWalk component, check AvoidFalling:true
  • press play

Creating a very simple melee weapon

  • fresh install of Corgi Engine v7.6 on 2019.4.39f1
  • open the MinimalLevel demo scene
  • create a new, empty game object, name it MyNewMeleeWeapon, add a MeleeWeapon component to it
  • drag this object into a folder in your project to make a prefab out of it, remove it from the scene
  • select the Rectangle prefab, drag the MyNewMeleeWeapon prefab into its InitialWeapon slot
  • press play, press E to attack (we didn’t setup any animation or visuals, so you’ll have to select your weapon’s damage area to see it activate)

Creating a very simple projectile weapon

  • fresh install of Corgi Engine v7.5.1 on 2019.4.36f1
  • open the MinimalLevel demo scene
  • create an empty game object, name it MyTestProjectileWeapon, position it at 0,0,0
  • add a ProjectileWeapon component to it
  • add a MMSimpleObjectPooler to it , set its GameObjectToPool to the MinimalMachineGunBullet prefab
  • optionally add a WeaponAim component to it
  • drag the MyTestProjectileWeapon in a folder in your project to make a prefab of it, remove it from your scene
  • select the Rectangle prefab, set the MyTestProjectileWeapon prefab as its InitialWeapon
  • press play in the editor, then E to shoot

Using the CharacterDetector

  • fresh install of CE v7.2.1 on Unity 2019.4.30f1
  • open the MinimalLevel demo scene
  • create an empty object, name it Detector, position it at -5,0,0
  • add a box collider 2D to it, set its size to 2,10, set IsTrigger:true
  • press play, walk to the right, when the character gets into the area, CharacterInArea turns true
  • feel free to trigger Unity events via the slots in the inspector

How to setup a character for slope orientation

  • in a fresh install of v7.5.1 of the Corgi Engine, on Unity 2019.4.34f1
  • open the MinimalSlopes demo scene
  • open the NewCorgi3D prefab, create an empty game object inside it, position it at 0,-0.4,0, name it RotationNode, and parent the SquashAndStretch node to it, without changing its position
  • save your prefab, return to the MinimalSlopes scene, and drag the NewCorgi3D prefab into the LevelManager’s PlayerPrefabs[0] slot
  • press play

Adding and setting up a Damage Dash ability

  • in a fresh install of v7.4 of the Corgi Engine, on Unity 2019.4.34f1
  • open the MinimalLevel demo scene
  • drag a MinimalShootingRangeTarget prefab in the scene, position it at -6,-4,0
  • edit the Rectangle prefab
  • add an empty child object to it, name it MyDamage, set its layer to Player, position it at 0,0,0
  • add a box collider 2D to it, set it to IsTrigger:true
  • press the AddComponent button, look for DamageOnTouch, add it
  • on its TargetLayerMask, check Enemies
  • on the top level object (Character), remove the CharacterDash ability
  • add a CharacterDamageDash ability
  • drag the MyDamage node into its TargetDamageOnTouch slot
  • set InvincibleWhileDashing to true
  • save your prefab, press play, press F to dash into the target

Setting up a feedback on a melee weapon

  • in this example we want to associate a feedback to the action of hitting a wall (or any non damageable element) with a weapon
  • fresh install of 7.4 on 2019.4.38f1
  • open RetroAI
  • edit the RetroComboSword prefab
  • add an empty child, name it WeaponHitWallsFeedback, add a MMFeedbacks to it
  • add a Debug>Log feedback to it, set its DebugMessage to “test”
  • on the 1st MeleeWeapon of the RetroComboSword, drag the WeaponHitWallsFeedback into the WeaponOnHitNonDamageableFeedback slot
  • save the prefab
  • press play, grab the sword, hit the wall on the left (with E)

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