Conditions - theRAPTLab/gsgo GitHub Wiki
See !116 (among others)
[[TOC]]
These do not rely on Physics.
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:
- You have to register the type of touch you want to monitor.
- 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
usescenterTouches
,centerFirstTouches
, andcenterLastTouches
. - e.g.
c2c
usescenterTouchesCenter
,centerFirstTouchesCenter
, andcenterLastTouchesCenter
Example:
useFeature Physics
useFeature Touches
featCall Touch monitor Algae c2c
when Fish centerTouchesCenter Algae [[ ... ]]
This will continually fire if the two agents are currently touching.
-
centerTouchesCenter
condition -- monitorc2c
-
centerTouches
condition -- monitorc2b
-
touches
condition -- monitorb2b
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 -- monitorc2c
-
centerFirstTouches
condition -- monitorc2b
-
firstTouches
condition -- monitorb2b
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 -- monitorc2c
-
centerLastTouches
condition -- monitorc2b
-
lastTouches
condition -- monitorb2b
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.
when Predator seesCamouflaged Moth