#Animation

1 messages · Page 1 of 1 (latest)

light eagle
#

Show me your animator parameter window before you press play

#

Make sure it's not already set to true

sonic estuary
#

just Button Trigger

light eagle
#

It's already set to true

#

It'll instantly move to the animation state

#

Turn it off

sonic estuary
#

Ah, that did fix it. Okay, but now how do I make it so that clicking the button will return it to its original state?

#

(forgive me for all the questions btw, i'm totally new to using the animation features)

light eagle
#

The same thing

#

You'll need to make an animation that plays the original state

#

Put that in the default state

#

Make a function that calls a trigger to activate transition from animation state to default state

sonic estuary
#

So I have one animation that goes from original position to new position [for the drawing board]. Do I have to make a whole new animation just to revert it back or is there a way to literally reverse the animation and go back to the default state?

#

Also, we declared Empty as default, right?

light eagle
#

You need to make a new animation that just plays the default rotation

sonic estuary
#

Right, so for that, that's a new animation for going from the new position to original, right?

light eagle
#

And put that in Empty

#

I dont know what your animation looks like

#

Does it end with it looking like default

sonic estuary
#

Here, I'll post two screenshots of the before and after

light eagle
#

I really don't have the time to hand hold this much

#

You should experiment with the animation

#

The setup is the same, just with a transition from the animation state to the empty state

sonic estuary
#

Okay, I'll try, sorry, but also thank you for helping.

sonic estuary
light eagle
#

I don't want you to lose confidence

#

Try first

sonic estuary
light eagle
sonic estuary
#

ah, thank you for that too

#

i was having trouble finding tutorials earlier

#

basic ones, anyway

light eagle
#

How do you create and script a button? Do you want to use the OnClick() Unity event? We'll go through that today, using TextMeshPro and the systems around it.

🎁 Get OVER 160+ Scripts, Projects and premium content on my PATREON HERE:
➡️http://bit.ly/SpeedTutorPatreon

············································································...

▶ Play video
light eagle
#

Good luck

sonic estuary
#

Yeah, I've already made a couple of other buttons, I've just been overworking myself on this project so I've been kinda getting a lot of easier things mixed up as well

#

But yeah, thank you again. ❤️

light eagle
#

Welcome. Bye!

sonic estuary
# light eagle Welcome. Bye!

Hi, I don't know if you're still available, and I got somewhere(?) with it, but I'm about one step away from finishing this and I cannot figure out where I'm going wrong here.

#

I created a Reverse Trigger for when it goes from BoardRotation to ReverseBoardRotation

#

What's currently happening, though, is that I'm in Empty at first, of course, but when I click my button in the UI, I go from Empty to BoardRotation and then it goes to ReverseBoardRotation and back to Empty again without me having clicked a second time.

#

And here's my transition between the two animations. I have it set to Reverse Trigger.

#

I also appended this to my script:

public void OnReverseButtonClick()
    {
        animator.SetTrigger("Reverse Trigger");
    }
#

And I gave my button another OnClick and I set it to that

light eagle
#

Well did you set the transition parameter

#

@sonic estuary

#

Don't use bool. You don't need it

sonic estuary
#

all 3 of them, for reference

light eagle
#

Code

sonic estuary
#
public class DrawingBoardAnim : MonoBehaviour
{
    [SerializeField]
    private Animator animator;

    public void OnButtonClick()
    {
        animator.SetTrigger("Button Trigger");
    }
    public void OnReverseButtonClick()
    {
        animator.SetTrigger("Reverse Trigger");
    }
}
light eagle
#

Buttons inspectors

sonic estuary
light eagle
#

It's just one button?

sonic estuary
#

Yeah, I'm trying to have it on one button if that's possible

light eagle
#

You put both actions on the one button

#

It's going to call both

#

On one click

sonic estuary
#

Ah. is there a way to do it with just one button?

light eagle
#

You will need to declare a bool inside your script

#

Set it to true when you animate the button

sonic estuary
#

Okay, ChatGPT gave me this:

using UnityEngine;

public class ButtonController : MonoBehaviour
{
    private bool isReversed = false;
    public Animator animator;

    public void OnButtonClick()
    {
        if (isReversed)
        {
            animator.SetTrigger("Reverse Trigger");
            isReversed = false;
        }
        else
        {
            animator.SetTrigger("Button Trigger");
            isReversed = true;
        }
    }
}
light eagle
#

Okay

#

Ew

sonic estuary
#

and then told me to just get rid of the transition between Board and Reverse

#

which confused me

light eagle
#

It's not wrong, but you didn't need chatGPT for that

#

That's because it's stupid and didn't know your exact situation

#

Do you know any coding at all

sonic estuary
#

I'm kinda rough at it

light eagle
#

My advice, stop relying on chat gpt

#

Because it's telling you things but you don't understand why

light eagle
#

You just need that bool logic

sonic estuary
# light eagle This code is fine Use it

Yeah, what it said for this was:

I apologize for the confusion earlier. You are correct that triggers do not have a greater/less than option in the dropdown menu. Instead, you can simply remove the condition on the transition from BoardRotation to ReverseBoardRotation altogether, and instead trigger the Reverse Trigger parameter in your code when the UI button is clicked a second time.

To do this, you can modify your button's OnClick event to include a script that triggers the Reverse Trigger parameter when the button is clicked. Here's some example code you can use:
[code here]
In this code, we're using a boolean variable isReversed to keep track of whether the button has been clicked once or twice. If it's been clicked once (isReversed is false), we trigger the "Button Trigger" parameter in the animator, which will transition from Empty to BoardRotation. If it's been clicked twice (isReversed is true), we trigger the "Reverse Trigger" parameter in the animator, which will transition from BoardRotation to ReverseBoardRotation.

Make sure to assign the animator variable in the inspector, and assign the OnButtonClick() method to your button's OnClick event.

light eagle
#

Not really interested

#

Just add the bool logic

#

And I hope you actually understand it

sonic estuary
light eagle
#

Yeah

#

That way it won't execute both at once

sonic estuary
# light eagle Oh and remove the OnReverseButtonClick

Okay, this is the new script:

public class DrawingBoardAnim : MonoBehaviour
{
    [SerializeField]
    private Animator animator;
    private bool isReversed = false;

    public void OnButtonClick()
    {
        if (isReversed)
        {
            animator.SetTrigger("Reverse Trigger");
            isReversed = false;
        }
        else
        {
            animator.SetTrigger("Button Trigger");
            isReversed = true;
        }
    }
}
light eagle
#

Just try it

#

Don't treat me as your compiler

#

Have confidence

sonic estuary
#

God damn, it actually works.

#

I've been at this bug for nearly 3 hours now

#

thank you, honestly

light eagle
#

Welcome, bye!