News Forums RAIN General Discussion and Troubleshooting Noob level 1 - Sensor/Aspect Variables

This topic contains 1 reply, has 2 voices, and was last updated by  CodersExpo 1 year, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #12801


    Hi, as a newbie at Unity & Rain i thank you a lot for all that work & ressources.
    Actually i try to do some basic concept & understand rain workflow, looked rain video tutorials, wiki / forum.
    My goal is to setup a very basic scene, to expose a concept (no need of full game’s behavior).

    This post will be a bit long regarding the question, but i hope explaining the setup will clarify it to me (& perhaps help someone).

    My question is relative to Aspect Variables & from where there are reachable, which method to choose.
    At the moment my basic AI & sensor seems to work fine.

    Setup - Basic Tower Defense - Based on the entity/aspect video tutorial

    AIMob is a capsule with:
    an entity EntityMob with an Aspect aMob (active)
    a behavior tree (constraint are for the next step - not essential, basic setup is just the capsule following the waypoint without constraint)

    — it’s also placed on a specific “Layer Mob”

    AITower is gameobject cubes with:
    a sensor TowerEyes (require lign of sight on)
    a behavior tree with constraints base on varMob & audio to hear if the detection worked (it works :) )

    Now the tower detect the mob in the range specified, what i wish to do is change the waypoint route when detected, and there is finally my problem.
    Wich is the best way to go from here, my point is, if possible, use mot of the GUI provided by RAIN for the moment, do not multiplicate entity/aspect/sensor if not needed.

    So i tried to setup constraints in the Mob_BehaviorTree with test on the aspect variable varMob of the Mob Entity.
    This don’t work, the TowerSensor detect the Mob & play the right audio, the mob don’t change his waypoint route (the second path seems ok, if i use it in first constraint it works).
    Does the aspect’s variables are exposed to self AI ?

    I also tried to code something, attaching a script to the parent of the AIMob (the capsule), adding a variable varDetected to the MobAI to have the possibility to change it if the TowerSensor detect the mob, and obviously change the constraint to based them on this varDetected.

    using UnityEngine;
    using System.Collections;
    using RAIN.Core;
    public class Detection : MonoBehaviour {
    	public GameObject CapsuleMob; //Assign the character with RAIN AI component
    	private AIRig AI_Mob; //This will be the RAIN AIRig component
    	// Use this for initialization
    	void Start () {
    		if(CapsuleMob != null)
    			AI_Mob = CapsuleMob.GetComponentInChildren<AIRig>();
    			if(AI_Mob != null)
    				//We have the character and AIRig. Get the memory and check if target gameobject variable was detected
    				var aiMemory = AI_Mob.AI.WorkingMemory;
    				var varDetected = aiMemory.GetItem<GameObject>("varDetected");

    At this point i don’t know where to go, is the GUI can do this directly ? Have to use code ?
    And the latter very noobish question - is there a way to display those variables (aspect or AIvariable) like a guitext to ease my understanding of variables state ?
    I saw a topic which describe a way in gui at running time but don’t succeed with it.

    For those who read that all way, congrat’s :)

    • This topic was modified 1 year, 2 months ago by  Tomates.


    “My question is relative to Aspect Variables & from where there are reachable, which method to choose.” - Script & Behavior Trees. What’s better depends on what you’re trying to do. Each is very effective.

    “Does the aspect’s variables are exposed to self AI” - Not sure what you’re asking here. Through script, the gameobject can access the component on self through GetComponentInChildren. The AI can access this component on another gameobject too. Play with sensor properties like ‘Requires Line of Sight’ if you need to detect the entity aspect even if it is hidden.

    “What i wish to do is change the waypoint route when detected.” - Create a waypoint route programmatically or at design time. Register it with Navigation Manager Instance. Follow this thread:

    “Is there a way to display those variables (aspect or AIvariable) like a guitext” - You can detect these in code, grab the value a save it to a working memory variable. Or, Sigil has a good article on exposing properties of a custom element so you can manage your own defined gameobject variables. See:

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.