Home Forums General Discussion A Problem With Move Nodes


This topic contains 1 reply, has 2 voices, and was last updated by  prime 5 days, 23 hours ago.

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


    So, I’ve got a move node set with Move Target = moveTarget. ‘moveTarget’ is a variable set in a script:

            protected GameObject moveTarget;	
    	public GameObject MoveTarget
    		get{ return moveTarget;}
    			moveTarget = value;
    			aiRig.AI.WorkingMemory.SetItem<GameObject>("moveTarget", moveTarget);			

    The Unity objects can have various behavior, seeking, avoidance, following waypoint routes, etc.

    When they first start up, if they don’t detect or have a target, they sit still (The Move node does not execute), which is fine. I note that in the AI memory, “moveTarget” does not exist. This is desired behavior.

    In my custom detection, I try to detect objects. If an object is found and is a valid target, “moveTarget” is set to that gameObject. Otherwise: “moveTarget” is set to null.

    Unfortunately, as soon as “moveTarget” is set to null, the object takes off headed for (0,0,0). In looking at the assembly browser for MoveAction, I see it does:

    if (this.moveTarget != null && this.moveTarget.IsValid)

    I would expect that this would prevent anything from happening if moveTarget was null. However, the local variable moveTarget is:

    public MoveLookTarget moveTarget = new MoveLookTarget();

    … and it seems to be using that if the ai memory variable assigned to the behavior tree ‘MoveTarget’ exists, but is null. This seems like a bit of a bug.

    Once I realized this it is pretty easy to get around:

    			if (moveTarget != null)
    				aiRig.AI.WorkingMemory.SetItem<GameObject>("moveTarget", moveTarget);

    ..but that is a bit of a hack. I doubt this is the intended behavior, so I thought I’d point this out.



    While we appreciate the help, I’ll remind everyone that decompiling and reverse engineering the code is a violation of the license agreement, as is posting any of the code here on the forums.

    I’ll look into the issue. Thanks

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

You must be logged in to reply to this topic.