Page 1 of 1

Using Sequences in C# Scripts

Posted: Wed Feb 16, 2022 1:54 pm
by annathehank
Hello again! Today I'm trying to wrap my head around how to use the sequencer commands in a script. I'm creating a sort of loot box system, and am trying to implement the MoveTo() sequence to help.
In the script I'm using, I have an array for the different objects you can find in the boxes, and I want to use the command to move the image of the object to an empty game object on the canvas. I'm a little worried doing a simple transform on the object to a location may get messed up as the camera moves around in the game.

This is the script so far. I'd like to add a line in the Onbuttonpress void that moves the moniObject being called forward to an empty gameobject.

Code: Select all

 public Moni[] monis;

    [System.Serializable]
    public class Moni
    {
        public string moniName;
        public GameObject moniObject;
        public int rating;
    }

    public void Onbuttonpress()
    {
       
            int moniIndex = Random.Range(0, monis.Length);
            Debug.Log("you have invited " + monis[moniIndex].moniName);
            Debug.Log("They are a " + monis[moniIndex].moniObject);
        
    }
Thank you in advance! <3

Re: Using Sequences in C# Scripts

Posted: Wed Feb 16, 2022 2:38 pm
by Tony Li
Hi,

To play a sequence in C# code, use DialogueManager.PlaySequence():

Code: Select all

DialogueManager.PlaySequence("MoveTo(Empty Box, MoniABC, 2)");
Another option, outside of the Dialogue System, is to use a tweening library such as DOTween. It's a useful tool for changing things from one value to another, such as moving an object from one position to another.

Re: Using Sequences in C# Scripts

Posted: Wed Feb 16, 2022 5:05 pm
by annathehank
Wow, it really was that simple, huh? :lol: I think I got myself thinking it was more complicated by looking at the reference guide and everything. Thank you!

Re: Using Sequences in C# Scripts

Posted: Wed Feb 16, 2022 5:10 pm
by Tony Li
Happy to help!