News › Forums › RAIN › General Discussion and Troubleshooting › Sensor not working
Tagged: Constraint, entity, Error, not working, sensor
This topic contains 14 replies, has 2 voices, and was last updated by Cubiboy 6 months, 2 weeks ago.
January 21, 2023 at 12:03 pm #39926
I try to finish my AI and setup 2 visual sensors to detect. To my Player I attached a Entity. In BT I wrote the Aspect and the
sensor with quotes but it’s still not working. Also in a constraint happens an error: varHeroNearby != null && myHealth > 0
Have you an idea to fix it?
Thank you very much!January 21, 2023 at 12:29 pm #39927
Can you post a screenshot of your behavior tree?
When you said the constraint has an error, do you mean that the expression is red or do you mean you are getting an exception in your console?January 21, 2023 at 1:37 pm #39928
Yeah here’s my BT: https://www.dropbox.com/s/9m7vy30irzgfcig/Screenshot%202016-01-21%2021.33.44.png?dl=0
Yes the expression is red and there is written “Failure” (enemy found).
Thanks for your help!January 21, 2023 at 1:49 pm #39929
OK, so I think the first issue is to switch the detect node from All Matches to Best. Currently All Matches returns a list of sensed aspects (even if there is only one) but the behavior tree can only really work with one at a time. All Matches is there if you want to create a custom action to do some additional work, and at some point we may support more in the expressions to actually go through that list in the behavior tree, not sure about that though.
Try that and see if that fixes your detect issues.January 21, 2023 at 1:53 pm #39930
No… unhappily not… same issue or rather no issue, because nothing happenJanuary 21, 2023 at 2:06 pm #39931
Did you set the other detect node to Best as well? If not make sure you set that as well. Even if it doesn’t fix the problem make sure you leave both of the detects on Best as it is the correct setting.January 21, 2023 at 2:21 pm #39932
Here’s my entity: https://www.dropbox.com/s/ais8wism146s4p2/Screenshot%202016-01-21%2022.20.34.png?dl=0
Any other ideas?January 21, 2023 at 2:31 pm #39933
The Entity and Aspect look good, let’s take a look at your sensors instead. I’m assuming you have two visual sensors, one named closeSensor and one named nearbySensor (maybe?).
Given the constraint that is failing, it is likely the nearbySensor that is keeping it from continuing (from your first post, varHeroNearby is likely null). So perhaps a quick screenshot of both sensors so we can see what they look like.January 22, 2023 at 9:04 am #39934
There are my two Sensors: https://www.dropbox.com/s/ga80kycgqa35cl9/Screenshot%202016-01-22%2017.03.07.png?dl=0January 22, 2023 at 9:14 am #39935
That looks good too. So I went back and looked at the entity screenshot and I noticed something I missed. Use Unity Messages is unchecked on the entity, which will keep it from registering the aspects with our system (unless you have some other code calling the initialization functions). Double check that all of your AI and entities have that checked, unless you are handling it in your own code.January 22, 2023 at 9:46 am #39936
NOW IT WORKS!!!
Thank you very much man!!!
Unchecked it to test and forget to check it again xD….January 22, 2023 at 9:53 am #39937
Glad we got it working.January 22, 2023 at 12:57 pm #39938
No I have an other problem… if the Enemy sees me and attacks me and I run away he rans towards me but if I’m too far away his animation stops and doesn’t run the “enemy not found” constraint…
Thanks a lot for your time you waste for me!January 22, 2023 at 4:02 pm #39941
It’s not a waste, no worries.
So it looks like you have your constraints set to repeat forever, which will block any chance of the constraint failing, keeping it from moving past the first one.
I imagine the reason you added the repeat is that your guy got stuck somewhere in the tree after doing something once (like attacking). Check your parallel node at the top and make sure the Fail and Succeed options are both set to Any. The tie breaker won’t matter in that case.January 23, 2023 at 6:25 am #39947
Thank you very much, that fixed it!!
You must be logged in to reply to this topic.