Problem with dynamic value

GameDragon

New member
Hi, I'm a beginner to Behavior Designer, so I very well might be overlooking something simple. I'm having a lot of inconsistencies with dynamic variables that I can't seem to figure out.

I have one custom node and one seek node that are using the same dynamic var. But 80% of the time, the Seek node's Target Position is zeroed out, and 20% it works without issue.

I also added image of my entire graph (the fork to the left is currently unused).

1754965912752.png1754965905782.png
 

Attachments

  • 1754965980805.png
    1754965980805.png
    55.1 KB · Views: 4
Within your own custom node are you using the Value property?
I am.

Code:
public class WithinRadiusPoint : Conditional
{
    // Inputs
    public SharedVector3 RadiusOrigin;
    public SharedFloat ValidRadius;
    public SharedFloat MaxMoveDistance = 10f;
    public SharedInt Attempts = 1;
    
    // Output
    public SharedVector3 TargetPosition;

    public override TaskStatus OnUpdate()
    {
        for (var i = 0; i < Attempts.Value; i++)
        {
            var unitCircle = Random.insideUnitCircle * MaxMoveDistance.Value;
            var randomPoint = transform.position + new Vector3(unitCircle.x, 0, unitCircle.y);
            
            if (!IsWithinRadius(RadiusOrigin.Value, randomPoint, ValidRadius.Value))
                continue;

            TargetPosition.Value = randomPoint;
            
            return TaskStatus.Success;
        }
        
        TargetPosition.Value = Vector3.zero;
        return TaskStatus.Failure;
    }

    private static bool IsWithinRadius(Vector3 center, Vector3 target, float radius)
    {
        var sqrDistance = (target - center).sqrMagnitude;
        var sqrRadius = radius * radius;
        return sqrDistance < sqrRadius;
    }
}
 
Hi, this looks strange, due to hardware issues I currently can't use Unity and look at the Seek script on my side, if you're interested I can still offer one screenshare for free to see what may be the cause of the issue, DM me if you're interested.
 
I think I have it figured it out actually. I was letting the Behavior Trees create the Behavior Manager instance automatically. I guess this screws up some kind of initialization process with the Seek node.

I created a Behavior Manager manually in my scene and it seems to be working consistently now.
 
Back
Top