News Forums RAIN General Discussion and Troubleshooting Animate node not working.

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

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

    lordofduct
    Participant

    So I can’t tell what’s going on here. Today I started playing with the legacy animations in RAIN. One of my animations won’t play, so I thought that it wasn’t rigged up correctly. But nope, it plays just fine… it’s my ‘chase’ animation, and if I play it where I usually play walk, it works fine. But if I play it in the charge part of my tree, it fails. Any animation I play there fails.

    This is the xml of my behavior tree right now:

    <behaviortree version="1.1" repeatuntil="" name="GatorBehaviour">
    	<parallel tiebreaker="succeed" succeed="any" repeatuntil="" name="root" fail="all">
    		<detect sensor=""Eyes"" repeatuntil="running" name="SeePlayer" entityobjectvariable="varPlayer" aspectvariable="" aspectobjectvariable="" aspect=""Player"" />
    			<selector usepriorities="False" repeatuntil="running" name="selector">
    				<constraint repeatuntil="" priority="" name="Chase Player" constraint="varPlayer != null">
    					<parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any">
    						<detect sensor=""AttackRange"" repeatuntil="" name="PlayerInHitRange" entityobjectvariable="varAttackPlayer" aspectvariable="" aspectobjectvariable="" aspect=""Player"" />
    						<selector usepriorities="False" repeatuntil="" name="selector">
    							<constraint repeatuntil="" priority="" name="Attack Player" constraint="varAttackPlayer != null">
    								<parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any">
    									<action repeatuntil="" parametervalues="ACJBdHRhY2si" parameters="QnJhaW4AQ29tbWFuZA==" namespace="(global)" name="attack" classname="ScriptForwardingAction" />
    									<animate repeatuntil="" name="animate" animationstate="melee_bite" />
    								</parallel>
    								<timer waitforsec="0.5" returnvalue="success" name="timer" />
    							</constraint>
    							<constraint repeatuntil="" priority="" name="Chase Player" constraint="varAttackPlayer == null">
    								<parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any">
    									<action repeatuntil="" parametervalues="ACJDaGFyZ2Ui" parameters="QnJhaW4AQ29tbWFuZA==" namespace="(global)" name="charge" classname="ScriptForwardingAction" />
    									<animate repeatuntil="running" name="animate" animationstate="chase" />
    								</parallel>
    							</constraint>
    						</selector>
    					</parallel>
    				</constraint>
    				<constraint repeatuntil="" priority="" name="Patrol" constraint="varPlayer == null">
    					<parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any">
    						<action repeatuntil="" parametervalues="ACJQYXRyb2wi" parameters="QnJhaW4AQ29tbWFuZA==" namespace="(global)" name="patrol" classname="ScriptForwardingAction" />
    						<animate repeatuntil="running" name="animate" animationstate="walk" />
    					</parallel>
    				</constraint>
    			</selector>
    	</parallel>
    </behaviortree>

    You can see there at line 19 of the xml, I animate ‘chase’.

    Also see that I do ‘walk’ at 28.

    If I put ‘chase’ into the node at 28, it plays, so I know the animation plays fine. And nothing I put into 19 works.

    The nodes that run in parallel with it run a script that move the player. Both are pretty much identical, one goes to a random point (patrol), the other chases the player. The code itself is pretty much identical otherwise. They both move the MOB appropriately and at the right speed, and return ‘RUNNING’ for its ActionResult.

    If you’re curious, this is the code it forwards to:

    using UnityEngine;
    using System.Collections.Generic;
    using RAIN.Core;
    using RAIN.Action;
    using RAIN.Motion;
    using com.spacepuppy;
    using com.spacepuppy.Utils;
    using com.apoc;
    using com.apoc.AI;
    public class GatorTypeActionSet : CompositeBrainComponent
    {
        #region Fields
        private ApocMovementMotor _motor;
        private GroundingResolver _groundingResolver;
        private FacingResolver _facingResolver;
        private JumpResolver _jumpResolver;
        private MoveLookTarget _moveTarget = new MoveLookTarget();
        public float PatrolSpeed = 2.0f;
        public bool TurnsAtLedge = true;
        public float ChargeSpeed = 5.0f;
        public string ChargeTargetVar;
        public bool LeapsAtLedgeWhenCharging = true;
        public float MaxGradient = 30.0f;
        #endregion
        #region CONSTRUCTOR
        protected override void Awake()
        {
            base.Awake();
            _motor = this.FindComponent<ApocMovementMotor>();
            _groundingResolver = this.FindComponent<GroundingResolver>();
            _facingResolver = this.FindComponent<FacingResolver>();
            _jumpResolver = this.FindComponent<JumpResolver>();
        }
        #endregion
        #region Actions
        RAINAction.ActionResult Patrol(RAIN.Core.AI ai)
        {
            float dir = (float)_facingResolver.FacingDirection;
            if (_groundingResolver.IsGrounded && this.TurnsAtLedge)
            {
                if (_groundingResolver.TestLedge(dir, this.MaxGradient))
                {
                    dir *= -1;
                }
            }
            //move towards target
            _moveTarget.VectorTarget = _motor.ProjectVectorTo3D(_motor.Position + Vector2.right * dir);
            ai.Motor.moveTarget = _moveTarget;
            ai.Motor.Speed = this.PatrolSpeed;
            if (ai.Motor is ApocStandardMotor)
            {
                return (ai.Motor as ApocStandardMotor).BlindMove() ? RAINAction.ActionResult.SUCCESS : RAINAction.ActionResult.RUNNING;
            }
            else
            {
                return ai.Motor.Move() ? RAINAction.ActionResult.SUCCESS : RAINAction.ActionResult.RUNNING;
            }
        }
        RAINAction.ActionResult Charge(RAIN.Core.AI ai)
        {
            if (this.ChargeTargetVar == null || !ai.WorkingMemory.ItemExists(this.ChargeTargetVar)) return RAINAction.ActionResult.FAILURE;
            _moveTarget.SetVariableTarget(this.ChargeTargetVar, ai.WorkingMemory);
            if (_groundingResolver.IsGrounded && this.LeapsAtLedgeWhenCharging && _jumpResolver != null)
            {
                if (_groundingResolver.TestLedge((float)_facingResolver.FacingDirection, this.MaxGradient))
                {
                    _jumpResolver.CacheJump();
                }
            }
            //move towards target
            ai.Motor.moveTarget = _moveTarget;
            ai.Motor.Speed = this.ChargeSpeed;
            if (ai.Motor is ApocStandardMotor)
            {
                return (ai.Motor as ApocStandardMotor).BlindMove() ? RAINAction.ActionResult.SUCCESS : RAINAction.ActionResult.RUNNING;
            }
            else
            {
                return ai.Motor.Move() ? RAINAction.ActionResult.SUCCESS : RAINAction.ActionResult.RUNNING;
            }
        }
        RAINAction.ActionResult Attack(RAIN.Core.AI ai)
        {
            return RAINAction.ActionResult.SUCCESS;
        }
        #endregion
        #region Utils
        #endregion
    }

    Help a brother out?

    • This topic was modified 1 year, 9 months ago by  lordofduct.
    • This topic was modified 1 year, 9 months ago by  lordofduct.
    • This topic was modified 1 year, 9 months ago by  lordofduct.
    #26705

    CodersExpo
    Participant

    I assume varAttackPlayer == null in the constraint “Chase Player”. Try making the Selector under PlayerInHitRange repeat. This is just a guess since what you have here is a bit complex to figure out by just reading through. My guess is that the Parallel parent has Fail if any so once it failed it does not attempt again to evaluate. If you repeat the Selector it will alow it to go back in and check again once varAttackPlayer != null has failed to see if varAttackPlayer == null is true. Just guessing.

    #26707

    lordofduct
    Participant

    Thing is the ‘charge’ command occurs, which runs along with the animation. The mob actually moves around on screen, the animation just doesn’t get called.

    I’ll have to play with it more. But it’s back to the work week again… hopefully by next weekend.

    • This reply was modified 1 year, 9 months ago by  lordofduct.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.