News Forums RAIN General Discussion and Troubleshooting RAIN + Dialogue System

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35025

    jayx2thez
    Participant

    Hello,

    I want to try and get my custom decision node to go to a waypoint only if a variable I detect in a dialogue system plugin from unity is true.

    Here is what I have:

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using RAIN.Action;
    using RAIN.Core;
    using PixelCrushers.DialogueSystem;
    [RAINDecision]
    public class convo : RAINDecision
    {
        private int _lastRunning = 0;
        public override void Start(RAIN.Core.AI ai)
        {
            base.Start(ai);
            _lastRunning = 0;
        }
        public override ActionResult Execute(RAIN.Core.AI ai)
        {
    		ActionResult tResult = ActionResult.FAILURE;
    		if (DialogueLua.GetVariable ("end").AsBool) {
    				tResult = ActionResult.SUCCESS;
    		}
    		for (; _lastRunning < _children.Count; _lastRunning++) {
    			tResult = _children [_lastRunning].Run (ai);
    			if (tResult != ActionResult.SUCCESS)
    		break;
    		}
    		return tResult;
        }
        public override void Stop(RAIN.Core.AI ai)
        {
            base.Stop(ai);
        }
    }

    Currently, as soon as I start the level, the move and animate child nodes immediately trigger and the NPC goes running. I want to have them conditionally trigger based on the value from the conversation system DialogueLua.GetVariable (“end”).AsBool.

    This is my first post, so please excuse any noob mistakes I might be making, any advice and assistance would be greatly appreciated.

    P.S. I asked this in an old thread a couple days back, but it got buried, so I’m starting a new one.

    • This topic was modified 1 year, 2 months ago by  jayx2thez.
    #35028

    jayx2thez
    Participant

    Figured it out. Solution below:

    public override ActionResult Execute(RAIN.Core.AI ai)
        {
    		ActionResult tResult = ActionResult.FAILURE;
    		//Checks Lua variable to detect the successful completion of a conversation with NPC
    		//If conversation complete, then children can execute and return success
    		//Custom decision node to repeat until success in the behavior editor
    		if (DialogueLua.GetVariable ("End").AsBool) {
    			for (; _lastRunning < _children.Count; _lastRunning++) {
    				tResult = _children [_lastRunning].Run (ai);
    				if (tResult != ActionResult.SUCCESS)
    			break;
    			}
    		}
    		return tResult;
        }
    • This reply was modified 1 year, 2 months ago by  jayx2thez.
    #35043

    prime
    Keymaster

    Sorry for the delay - already gave my answer as a reply to the other post.

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

You must be logged in to reply to this topic.