I have an enemy called TRex that can follow the player with the RAIN package’s built-in visual sensors. Like any TRex, it should not be able to detect the player if the player hasn’t moved in a short amount of time. I have no idea how to begin writing a script for the TRex because the script has to reference the AI’s visual sensor and the player.
A person on reddit gave me an example to initially fix my TRex because it wasn’t following the player.
The code for the AI:
<component version="1.1" type="RAIN.Core.AIRig"><fields><field value="True" type="System.Boolean" id="_showVisual" /><field value="True" type="System.Boolean" id="_useUnityMessages" /><field value="False" type="System.Boolean" id="_useFixedUpdate" /><field type="RAIN.Core.AI" reference="0" id="_ai" /></fields><references><reference type="RAIN.Core.AI" refcount="1" id="0"><field value="True" type="System.Boolean" id="_isActive" /><field type="UnityEngine.GameObject" id="_body" gameobject="0" /><field type="RAIN.Memory.BasicMemory" reference="1" id="_workingMemory" childrenvisible="False" /><field type="RAIN.Minds.BasicMind" reference="2" id="_mind" childrenvisible="False" /><field type="RAIN.Motion.BasicMotor" reference="3" id="_motor" childrenvisible="False" /><field type="RAIN.Animation.BasicAnimator" reference="4" id="_animator" childrenvisible="False" /><field type="RAIN.Navigation.BasicNavigator" reference="5" id="_navigator" childrenvisible="False" /><field type="RAIN.Perception.BasicSenses" reference="6" id="_senses" childrenvisible="True" /><field type="System.Collections.Generic.List" id="_customElements" elementtype="RAIN.Core.CustomAIElement" childrenvisible="False" /></reference><reference type="RAIN.Memory.BasicMemory" refcount="1" id="1"><field type="System.Collections.Generic.List" id="_memoryItems" elementtype="RAIN.Memory.BasicMemory+MemoryItem" /></reference><reference type="RAIN.Minds.BasicMind" refcount="1" id="2"><field type="RAIN.BehaviorTrees.BTAsset" id="_behaviorTreeAsset" gameobject="1" /><field type="System.Collections.Generic.List" id="_behaviorTreeBindings" elementtype="RAIN.BehaviorTrees.BTAssetBinding" /></reference><reference type="RAIN.Motion.BasicMotor" refcount="1" id="3"><field value="6" type="System.Single" id="_speed" /><field value="180" type="System.Single" id="_rotationSpeed" /><field value="0.1" type="System.Single" id="_closeEnoughDistance" /><field value="0.001" type="System.Single" id="_closeEnoughAngle" /><field value="90" type="System.Single" id="_faceBeforeMoveAngle" /><field value="0.5" type="System.Single" id="_stepUpHeight" /><field value="False" type="System.Boolean" id="_allow3DMovement" /><field value="False" type="System.Boolean" id="_allow3DRotation" /><field value="False" type="System.Boolean" id="_allowOffGraphMovement" /></reference><reference type="RAIN.Animation.BasicAnimator" refcount="1" id="4"><field type="System.Collections.Generic.List" id="_animationStates" elementtype="RAIN.Animation.BasicAnimator+BasicAnimatorState" /></reference><reference type="RAIN.Navigation.BasicNavigator" refcount="1" id="5"><field value="False" type="System.Boolean" id="_drawPaths" /><field value="100" type="System.Int32" id="_maxPathfindingSteps" /><field value="0" type="System.Single" id="_maxPathLength" /><field type="System.Collections.Generic.List" id="_graphTags" elementtype="System.String" /></reference><reference type="RAIN.Perception.BasicSenses" refcount="1" id="6"><field type="System.Collections.Generic.List" id="_sensors" elementtype="RAIN.Perception.Sensors.RAINSensor"><field type="RAIN.Perception.Sensors.VisualSensor" reference="7" id="element0" /></field></reference><reference type="RAIN.Perception.Sensors.VisualSensor" refcount="1" id="7"><field value="True" type="System.Boolean" id="_showVisual" /><field value="Sight" type="System.String" id="_sensorName" /><field value="True" type="System.Boolean" id="_isActive" /><field value="0.6,0,0,1" type="UnityEngine.Color" id="_sensorColor" /><field type="UnityEngine.Transform" id="_mountPoint" gameobject="2" /><field value="0,0,0" type="UnityEngine.Vector3" id="_positionOffset" /><field value="0,0,0" type="UnityEngine.Vector3" id="_angleOffset" /><field type="System.Collections.Generic.List" id="_filters" elementtype="RAIN.Perception.Sensors.Filters.RAINSensorFilter" /><field value="90" type="System.Single" id="_horizontalAngle" /><field value="360" type="System.Single" id="_verticalAngle" /><field value="28.63" type="System.Single" id="_range" /><field value="False" type="System.Boolean" id="_canDetectSelf" /><field value="True" type="System.Boolean" id="_lineOfSight" /><field value="512" type="UnityEngine.LayerMask" id="_lineOfSightMask" /></reference><reference type="RAIN.Perception.Sensors.Filters.NearestXFilter" refcount="0" id="8" /></references></component>
Edit: Took out the download link for the example project, even though it was legitimate.