Skip to content

Object motion callbacks added #3

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

Open
QQ1273459693 opened this issue Mar 28, 2024 · 1 comment
Open

Object motion callbacks added #3

QQ1273459693 opened this issue Mar 28, 2024 · 1 comment

Comments

@QQ1273459693
Copy link

It would be perfect if you could implement a callback after each movement, e.g., after object A moves to position B, I'll move A to position C again, and then I'll call the callback after each movement.

@DhafinFawwaz
Copy link
Owner

Try this
Callback in AnimationUI

Bassically its:

  1. Move transform A From position A to potition B for x seconds
  2. Wait x seconds
  3. Call unityevent
  4. Move transform A From position B to potition C y seconds
  5. Wait y seconds
  6. Call unityevent

Instead of callback in each sequence, you can add an event that calls the function you want to call.

Or you can also do it with code like this if you don't want to add it in the inspector. (I didnt make a clear documentation for it tho):

using UnityEngine;

public class CallbackTest : MonoBehaviour
{
    // Assign the AnimationUI component in the inspector
    [SerializeField] AnimationUI animationUI;

    void Start()
    {
        animationUI.AnimationSequence[2].Event.AddListener(AfterAMoveToB);
        animationUI.AnimationSequence[5].Event.AddListener(AfterAMoveToC);
    }

    void AfterAMoveToB()
    {
        Debug.Log("Callback After A move to B");
    }

    void AfterAMoveToC()
    {
        Debug.Log("Callback After A move to C");
    }
}

Another alternative is to add multiple AnimationUI component. Then look at the Readme.md and use the AddFunctionAtEnd to each animation. Make sure the second one has wait sequence.

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

2 participants