Conditions - theRAPTLab/gsgo GitHub Wiki

See !116 (among others)


[[TOC]]


Non-Physics Conditions

These do not rely on Physics.

isCenteredOn condition

isCloseTo condition


Touches Conditions

See Touches for more information.

These require Physics and Touches.

  • center-to-center (c2c) -- The two agents' centers are within a short distance of each other (currently set to 10 to accommodate jitter). This is generally used for predation when you want one agent on top of another before triggering an action.
  • center-to-bounds (c2b) -- The first agent's center touches the physics body rectangle of the second agent. This is typically used for "landing" on another larger object. You can't use center-to-center because the larger objects' center might be far away.
  • bounds-to-bounds (b2b) -- The physics body rectangle of both agents are touching each other. This is typically used for collision tests. It can be deceptive because physics bodies are typically larger than the sprite costume if there is extra transparent space in the sprite costume.

To use these, you need to:

  1. You have to register the type of touch you want to monitor.
  2. Use the corresponding condition test

IMPORTANT: Each touch type has a corresponding touch test. Use the wrong test, and the touch won't register!

  • e.g. c2b uses centerTouches, centerFirstTouches, and centerLastTouches.
  • e.g. c2c uses centerTouchesCenter, centerFirstTouchesCenter, and centerLastTouchesCenter

Example:

        useFeature Physics
        useFeature Touches
        featCall Touch monitor Algae c2c

        when Fish centerTouchesCenter Algae [[ ... ]]

Is Touching

This will continually fire if the two agents are currently touching.

  • centerTouchesCenter condition -- monitor c2c
  • centerTouches condition -- monitor c2b
  • touches condition -- monitor b2b

First Touches

This will fire once when the two agents first touch each other. They were not touching in the last frame, and are now currently touching.

  • centerFirstTouchesCenter condition -- monitor c2c
  • centerFirstTouches condition -- monitor c2b
  • firstTouches condition -- monitor b2b

Last Touches

This will fire once when the two agents stop touching each other. They were touching in the last frame and are not currently touching.

  • centerLastTouchesCenter condition -- monitor c2c
  • centerLastTouches condition -- monitor c2b
  • lastTouches condition -- monitor b2b

seesCamouflaged condition

Returns true if the source agent can detect the target agent's color against the target agent's background agent. If the target agent's color is too similar to the target agent's background agent color then the target agent is not seen.

Set the source agent's color*DetectionThreshold Vision properties to set the detection threshold.

Syntax

when Predator seesCamouflaged Moth

⚠️ **GitHub.com Fallback** ⚠️