Stop a game object from following an untagged object.

When making game object follow something with tag, but then untagg it while running, why it keeps follow it?
even if i instantiate another object that was supposed to follow the previously tagged object, it just keep moving towards it. please how to get an object to stop or just follow another tagged object when the targed is no longer tagged ? thanks

@MounirDev, There is no magical property that tells your object to follow an object with with a tag, or to stop following it if the tag changes. You have to set that in your movement code.

The problem you have is that when you object becomes utagged, your movement code is still doing the same thing. Instead you need it to do something different if the tag changes

One way to do it is for your code to follow this kind of logic:

Keep a referece to the  oldTargetObject
Keep a reference to the targetObject
Movement loop begins here {
        if I am walking then targetObject tag = what I want
        else if I am running  targetObject tag = something else
        if targetObject tag = what I want
                 move to targetObject position
                 move to oldTargetObject position