News Forums Developer Program Picking RAIN's Brain

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

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


    I know most you developers know how to disassemble libraries when you need implementation examples of the API or object browser class descriptions. Some individuals might find this of value though.

    Check out .Net reflector from NET Reflector is a class browser and analysis tool for .NET, that allows you to navigate, search, disassemble and analyze .NET components. Why is this important, well let me just say, if you really want to understand what’s going on under the covers you will find this tool invaluable.

    Ok, so you are working with the Entity/Aspects and Sensors. While debugging you can only step into your Unity scripts or the RAIN custom actions but the stuff going on inside the classes handling the detection for example is unavailable to step into.

    What you might do is use reflector (or your object browser or the RAIN API) to learn how to get or implement your own versions of these classes. A very simple way to start, is using reflector, so you can view the code for the RAIN.Perception BasicSenses and RAIN.Perception.Sensors. Create your own class that implements these classes or their base class and copy the code you need to work through and/or create some of your own custom methods.

    Once you have provided the correct inheritance and class/property/method attributes and implementations, your new class will be displayed in the RAIN components on your inspector. Sounds like a lot but its actually quite simple. This way, now you can step into the code that is doing all the heavy RAIN work and better understand the ‘what and how’ of it.

    Want to see a very simple example of this go to to read up on it and download a sample project. Be sure to post here if you have any questions, find errors or would like to see other examples.




    I’m thinking reflection would be useful for modifying derived classes of RAINAction at runtime to obtain references to Unity Components that are attached to the AI.Body GameObject without having to repeatedly call GetComponent on AI.Body to get the job done. Not to be a knit picker, RAIN is awesome, but it would be nicer if references to Unity Components can be made in RAINAction Nodes through the RAIN Behavior Editor and within the RAINAction class, but so that Unity doesn’t have to fetch the reference to the Components every time the Node is visited. Also, not to just limit this to Components, but to be able to grab references to instances to anything to be continuously accessed by the Node would be nice. My workaround has been to assign a reference to components if a variable to the component reference is null, but this is an extra check for each component that is to be used inside the node every time the node is visited. I’ve been working with RAIN for a couple weeks in my spare time and I’m still learning better ways to get things done.

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

You must be logged in to reply to this topic.