Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make OnUpdate and ChangeEndValue work properly? #669

Open
arthursun opened this issue Dec 26, 2023 · 0 comments
Open

How to make OnUpdate and ChangeEndValue work properly? #669

arthursun opened this issue Dec 26, 2023 · 0 comments

Comments

@arthursun
Copy link

arthursun commented Dec 26, 2023

I want to make object 1 to follow object 2, within a fixed time(when object 2 moves to opposite direction, it should makes object 1 to move faster in order to keep the whole move time fixed).

Problem 1: The following codes do not work at all. obj1 doesn't move at all. Not sure if it's a bug.

    var tweener = obj1.transform.DOMove(obj2.transform.position, 5f);
    tweener.OnUpdate(() => {
        tweener.ChangeEndValue(obj2.transform.position);
    });

Problem 2: Using the following codes, obj1 moves and follows obj2. However its speed reduces gradually and never reaches obj2. I think the ChangeValues call must have reset the duration to 5 somehow.

    var tweener = obj1.transform.DOMove(obj2.transform.position, 5f);
    tweener.OnUpdate(() => {
        tweener.ChangeValues(obj1.transform.position, obj2.transform.position);
    });

If I know how to get the remaining duration time of a tweener, and maybe this following codes may work properly. But I haven't found a way to get te remaining duration in documentation.

    var tweener = obj1.transform.DOMove(obj2.transform.position, 5f);
    tweener.OnUpdate(() => {
        tweener.ChangeEndValue(obj2.transform.position);
        tweener.ChangeValues(obj1.transform.position, obj2.transform.position, newDuration: tweener.currentRemainingDuration);
    });

Any help is appreciated, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant