- Home /
Question by
Fredy32 · Feb 06, 2021 at 04:15 AM ·
movementaigamefindgameobjectwithtag
AI needs find and move towards multiple different objects
I need to make an AI for an Animal in my game prototype. Right now the animal will randomly walk around and when it contacts food it will eat it. but it has no way of detecting and moving toward the food. the script needs to have a variable that changes a radius around the animal. if there is food in the radius it will move toward it. but there are multiple kinds of food so I think I need to find a tag not a game object. but idk, please help!
Comment
Answer by logicandchaos · Feb 06, 2021 at 01:51 PM
use OverlapCircleAll() to get everything in range, then you can filter by object type or distance.
will that work for a 3d game? I forgot to mention that it was a 3d game.