News › Forums › General Discussion › Possible Bug with Random BT Node
Tagged: Behavior Tree, Constraint, NavTarget, random
This topic contains 12 replies, has 2 voices, and was last updated by prime 1 month ago.
November 16, 2022 at 9:47 pm #34183
I’m not sure if this is a Bug or a Feature, but I have a BT setup where my flying enemies use a Random node to select a new NavTarget from a selection of 6. This works perfectly fine as is.
The problem occurs when I try to add a Constraint (without a Selector) that runs in parallel with the Random node. Basically, when the enemy sees an Asteroid, it is supposed to start shooting. I have the Detect node working properly. I want the enemy to start shooting, but to maintain course toward the random NavTarget.
The actual problem is that when I have that Constraint added, the Random node goes haywire and keeps trying to pick a NavTarget instead of selecting one and sticking with it until success (the way it does normally).
Does the Constraint require a Selector in order to work?
Is there a better implementation for starting one behavior while maintaining another?
-Iuxeayor ;>November 16, 2022 at 9:57 pm #34186
https://drive.google.com/file/d/0ByMshOYaDFucaTdfc095T1F1TDA/view?usp=sharing>November 17, 2022 at 8:22 am #34193
How is the parallel set up? Is it set to fail on any? If so, whenever the constraint fails it will reset the parallel (and cause the random to reset.) I’d have to see more of the behavior tree to understand what you actually want to have happen.November 17, 2022 at 11:11 am #34197
Alrighty. I’m at work right now and won’t be able to get back to my project until another 6 hours or so. I will get you that information at that time. If it helps any, I left everything on the Parallel as its defaults. Repeat should be Never, I think. I will try to get you an image of the rest of the BT, as well.
Thanks ;>November 18, 2022 at 6:30 pm #34342
Sorry this took so long. Originally, I had Fail set to the default which was Any. I tried setting that to All and I have been experimenting, but so far, to no avail. I will get a Screenshot of my full BT shortly. ;>November 18, 2022 at 6:34 pm #34343November 18, 2022 at 6:44 pm #34344
I think I figured it out.
Then the Constraint needs to be set to Repeat:Forever.
I’m assuming that the Constraint was only being checked once every time a NavTarget was hit and then not again until the next one. Setting the Repeat to Forever seems to have told it to run every frame. Correct me if I’m wrong.
-Iuxeayor ;>November 19, 2022 at 7:55 am #34349
Constraints are checked every frame - that’s their primary purpose. They are used to ensure that a certain condition remains true when any child nodes try to run.
In the BT pic you posted, I don’t know what the custom action is inside the constraint in the Move Somewhere branch. Seems strange that it is set to repeat until Failure, but would be running inside a Constraint set to repeat forever.November 19, 2022 at 8:18 am #34351
Yeah, I didn’t name the nodes on that part of the tree because they were still in testing. The Custom Action is to fire one blast, so that when set to Repeat:Until Failure, it shoots very rapidly. Again, just a sketch as it would adopt the same branches as shooting the player once I got it to do the simple thing first.
Based on my tests, it looks like the Constraint was only looked at once until the Random passed a Succeed. By setting it Repeat:Forever, it was tested each frame and worked the way that I wanted it to, thereby not caring whether the Random was returning Succeed or not. Should this not be the case?November 19, 2022 at 6:15 pm #34358
Does the Visual Aspect have to completely fit inside the Visual Sensor in order for the Sensor to see it?November 19, 2022 at 9:15 pm #34362
Constraints are tested each frame as long as they are active, regardless of what the child nodes are doing and regardless of what you set their repeat value to. If the Constraint was not being tested, it would be because it had already run and either succeeded or failed.
A visual aspect is a point in space - it doesn’t have any dimensions so there isn’t a notion of “completely inside”. The point is either in or out of the sensor range. The sensor does not detect the dimensions of the object that the aspect is attached to.November 22, 2022 at 5:17 pm #34388
One last question, then. You say that the Visual Aspect is just a point in space. Does that mean that scaling the “Visual Size” doesn’t do anything to let the sensor see it if the sensor only sees the edge and not the center of the aspect?November 23, 2022 at 8:00 am #34389
That is correct. Scaling the size of a Visual Aspect does not change its visibility to sensors. Sensors will only see the center of the aspect.
You could certainly create custom sensors that behave differently from that. The VisualSensor has a TestVisibility method that determines whether an Aspect is in range. You could extend the check to include a volumetric calculation.
You must be logged in to reply to this topic.