0
\$\begingroup\$

I have prefab and its hierarchy is as follows:

bird

-Outline

--mask

--filler

Now I am using this in Update to move the filler:

filler.gameObject.transform.position = Vector3.MoveTowards(
            filler.gameObject.transform.position,
            new Vector3(feedBar.gameObject.transform.position.x, -1.1f, filler.gameObject.transform.position.z),
            (1f / PlayerPrefs.GetFloat("timetofeedbird", 5)) * Time.deltaTime);

All the instantiated birds have movement in correct direction. But the last one has a movement in reverse direction.

Here is the GIF to explain the issue:

enter image description here

Any idea what the issue here?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

So I solved this issue. I don't quite understand it but what did the trick for me was I changed the value of maxDistanceDelta to negative. And now its working as expected.

filler.gameObject.transform.position = Vector3.MoveTowards( filler.gameObject.transform.position, new Vector3(feedBar.gameObject.transform.position.x, -1.1f, filler.gameObject.transform.position.z), -(1f / PlayerPrefs.GetFloat("timetofeedbird", 5)) * Time.deltaTime);

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .