Can See Object by tag

Rick

New member
Hello. I'm playing around with Behavior Designer. I'm creating a character who has a hunger value and when it drops below 75 they'll wander until they see food in which case they should then seek to that food. The issue I'm having is Can See Object is returning the first thing it sees even though I have "Food" in the Target Tag field and this wall that it sees doesn't have "Food" as it's tag.

I have Can See Object return to a FoodObject variable I made and Seek looks for that. However when it's running I see this variable get changed to a cube which is a wall not the food. Am I not using this Target Tag right? My assumption was that Can See Object would return true when it see's a game object that has the "Food" tag and false if it doesn't.

1601927883056.png
 
Last edited:
It should be using the tag version - can you insert a breakpoint within CanSeeObject.OnUpdate to see if it gets to GameObject.FindGameObjectsWithTag?
 
First issue was the script variable wasn't getting populated with what I typed (Food) for some reason. The variable was null. You can see I did type it in above though. So I cleared it out and retyped it and now that's coming through. It means it "sees" it when it's in the view cone. However it then calls the method below and Linecast() never returns true which prevents it from bringing back the food object.

1601992315581.png
 

Attachments

  • 1601992161770.png
    1601992161770.png
    58.4 KB · Views: 1
Last edited:
Ahh, it looks like you are using a dynamic variable? Your dynamic variable doesn't have a value so that's why it is null. If you just want to use "Food" you should not create a dynamic variable (click the little circle so it's not pressed) and type in "Food".

The dropdown is a SharedString so it is looking for the string variables in your graph.
 
Any thoughts on Linecast() not coming back with a hit ever? I moved up the positionOffset because my player has this at their feet so I thought maybe it was half inside the ground and it was hitting the ground but that didn't help. Also it's misleading or strange to have the view cone move with that because the view cone starts in the center of my character. Visually it also looks like a flat plane so you don't get any vertical idea with it.

Food is on the default layer and you can see my settings in the original post for the settings so I'm not sure why the lines aren't connecting when visually they look like they should be.
 
You can enable debugging on the task which should help track down what it is doing. This page has the definitions for what each color line means: https://opsive.com/support/documentation/behavior-designer-movement-pack/

Food is on the default layer and you can see my settings in the original post for the settings so I'm not sure why the lines aren't connecting when visually they look like they should be.
In your original image you are using a dynamic variable. This will then map to an empty string because the Food variable has not been set. For right now you should not use a dynamic variable.
 
The food collider was marked as a trigger. That was why. Thanks for your help!
 
Last edited:
Top