This page describes how the AI scripts of the Corgi Engine work.


A bunch of AI controlled characters walking around in their natural habitat.

Right now the engine includes a few basic AI scripts for your enemies (or friends). These are components you can add to your characters (simply via the AddComponent button at the bottom of the character’s inspector), and it’ll make them perform actions without the need for input from the player. To use them, you need to have a Character setup properly, with (at least) the required components for each AI script. Each AI script may require certain particular Abilities, but all of them require that you have a CorgiController and a Character. You can also try combining them : for example you can add AI ShootOnSight and AI Walk to a Character and it’ll be able to walk around and shoot at your player. More AI scripts are coming soon to help you create more diverse enemies, but feel free to create your own AI scripts, it’s really easy and fun to do.

AI ShootOnSight

This component requires a CharacterHandleWeapon component. What it does is cast raycasts to its left and right, targeting the objects on the layers you’ll have specified in its inspector. If one object hits these raycasts, the AI will shoot at it using its current equipped weapon.

AI Walk

This component requires a CharacterHorizontalMovement component. It’ll allow your AI character to walk. You can specify the desired behaviour in its inspector. From there you can have it patrol (walk randomly and change direction when hitting a wall or optionnally a hole), or walk on sight, which means the AI will “look” (using raycasts) for objects on the layers you’ll have specified in its inspector. If a raycast hits such an object, the character will move towards it.

AI Follow

This component requires a CharacterHorizontalMovement component. Add this script to a Character to make it follow (or try to follow) the main Player character. If it has a CharacterRun component it’ll try to run when far from target. If it has a CharacterJetpack it’ll try to jetpack over obstacles to reach the target, and if it has a CharacterJump component it’ll try to jump over obstacles.