Same objects following different tags in Unity3D

Hello! I’ve been trying to make an object follow another object, which I managed thanks to the community. The object follows his target fine, but here’s the issue. I want to make objects of the same prefab follow targets with different tags. Is there a way to do that?

Sure, you could create a string variable “followTag”, for example, that has to be public or have an attribute [SerializeField], so you can see and change it on the script inspector. Then for each of those game objects in the scene you need to manually give a specific tag name to chase, using this followTag variable in your script to define what it’s going to follow. Would this fix it, or this solution does not go along what you were thinking?

Doing it in the same prefab it not the way to go. You should make each of them a different prefab and name them accordingly. Then in the script instead of haveing it where it says

{
Your_Variable.GetComponentTag<“player”>;
}

You should make the script say

{
Public GameObject Track_This;

Your_Variable.GetComponentTag;
}

This is so you can change it in the inspector

Thank you for your answers. I will just make a few prefabs with different follow tags to make it easier. I just wanted to make it cleaner using code, but that’s too complicated for my level.

Doing it in the same prefab it not the way to go. You should make each of them a different prefab and name them accordingly. Then in the script instead of haveing it where it says

{
Your_Variable.GetComponentTag<“player”>;
}

You should make the script say

{
Public GameObject Track_This;

Your_Variable.GetComponentTag;
}

This is so you can change it in the inspector