Game Creator
  • Welcome to Game Creator!
  • Quickstart
    • Get Started
    • Setup
    • Tutorials
  • Game Creator
    • Game Creator
      • Actions
      • Conditions
      • Triggers
      • Hotspots
      • Characters
        • Player
        • Markers
        • Gestures
        • States
        • Advanced
          • IK in custom Animations
      • Camera
        • Camera Motors
      • Variables
        • Global Variables
        • Local Variables
        • List Variables
    • Systems
      • Localization
      • Event System
      • Timeline
      • UI
      • Module Manager
      • Game Creator Toolbar
      • Pool System
      • Game Creator API
        • Custom Actions
        • Custom Conditions
        • Custom Triggers
        • Custom Hooks
        • Custom Save & Load
        • Variables Access
        • Custom Module
  • Dialogue
    • Dialogue
      • Anatomy
      • Actors
      • Dialogue UI
      • API
  • Inventory
    • Inventory
      • Inventory Window
        • Catalogue
        • Recipes
        • Types
        • Settings
      • Merchants
      • Containers
      • Loot Tables
      • Equip Items
      • Actions
      • Conditions
      • Custom Inventory UI
  • Quests
    • Quests
      • Quests Overview
      • Create Quests
      • Quests UI
        • Custom UI
  • Stats
    • Stats
      • Stats Overview
        • Stat
        • Attributes
        • Status Effects
        • Formulas
        • Stat Modifiers
      • Stats UI
      • Common Use Cases
        • Simple Health Bar
        • Regenerative Mana
        • Poison Status Effect
        • Levels and XP
        • Strength and Armor
        • Lockpicking
  • Behavior
    • Behavior
      • Behavior Graph
        • Nodes
        • Blackboard
      • Perception
  • Shooter
    • Shooter
      • Weapons
      • Ammunition
      • Interaction
      • Examples
        • Example 1 - Get Started
        • Example 2 - Pick Weapons
        • Example 3 - Top Down
        • Example 4 - Side Scroll
        • Example 5 - First Person
        • Example 6 - Combat
      • Advanced
        • Custom Crosshairs
        • Shooter API
  • Melee
    • Melee
      • Weapons
        • Blade Component
      • Shields
      • Melee Clips
      • Combat
  • Traversal
    • Traversal
      • Obstacles
      • Climbables
      • Built-in Elements
  • Annex
    • Roadmap
    • FAQ
Powered by GitBook
On this page

Was this helpful?

  1. Game Creator
  2. Systems
  3. Game Creator API

Custom Conditions

PreviousCustom ActionsNextCustom Triggers

Last updated 7 years ago

Was this helpful?

Creating custom Conditions is much like creating custom Actions but even easier. If you haven't taken a look at how to create Actions it is encourage that you do so, as the process is practically the same.

To create a custom Condition right-click in the Project Panel, select Create → GameCreator → Condition and give it a suitable name. Because the template file is a too simple Condition example, we're going to create a more complex one through this manual. We're going to create a **Condition that checks whether two objects are within a certain radius.

We use the convention "Condition" + name, but you can use whatever you like.

A Condition code is divided in a runtime section and an editor section.

The runtime section describes how it checks whether something is true or false. To do so, declare your properties below the class definition and override the Check method. To create the new Condition let's remove the isSatisfied property and create 3 others:

public Transform objectA;
public Transform objectB;
public float maxDistance = 5.0f;

And finally fill the Check() method. To check whether objectA is within a distance of maxDistance respect objectB we calculate the distance between the two objects and return if the value is lower than the threshold.

public override bool Check(GameObject target)
{
    if (this.objectA == null) return false;
    if (this.objectB == null) return false;
​
    float distance = Vector3.Distance(
        this.objectA.position,
        this.objectB.position
    );
​
    return (distance <= this.maxDistance);
}

The Editor section of a Condition is exactly as the Action. Check it out clicking .

here