#Animation
1 messages · Page 1 of 1 (latest)
Show me your animator parameter window before you press play
Make sure it's not already set to true
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)
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
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?
.
You need to make a new animation that just plays the default rotation
Right, so for that, that's a new animation for going from the new position to original, right?
And put that in Empty
I dont know what your animation looks like
Does it end with it looking like default
Here, I'll post two screenshots of the before and after
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
Okay, I'll try, sorry, but also thank you for helping.
ahh okay, that makes more sense
i will, don't worry. this was helpful, though. i do appreciate it. c:
In this unity tutorial we will take a look at animation transitions !
In other words, we will get our character smoothly going from one animation state to another (idle to run or run to jump for example) using the animator controller and a bit of C# !
--------------------------------------------------------------------------------------------...
ah, thank you for that too
i was having trouble finding tutorials earlier
basic ones, anyway
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
············································································...
This is what you did, kinda. More basic
Good luck
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. ❤️
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
Well did you set the transition parameter
@sonic estuary
Don't use bool. You don't need it
Yeah, I changed it back to button. Here's a screenshot of what I got so far for my transitions:
all 3 of them, for reference
Code
public class DrawingBoardAnim : MonoBehaviour
{
[SerializeField]
private Animator animator;
public void OnButtonClick()
{
animator.SetTrigger("Button Trigger");
}
public void OnReverseButtonClick()
{
animator.SetTrigger("Reverse Trigger");
}
}
Buttons inspectors
It's just one button?
Yeah, I'm trying to have it on one button if that's possible
Ah. is there a way to do it with just one button?
You will need to declare a bool inside your script
Set it to true when you animate the button
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;
}
}
}
and then told me to just get rid of the transition between Board and Reverse
which confused me
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
I'm kinda rough at it
My advice, stop relying on chat gpt
Because it's telling you things but you don't understand why
This code is fine
Use it
You just need that bool logic
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.
Not really interested
Just add the bool logic
And I hope you actually understand it
So I take off one of the OnClicks, right?
Oh and remove the OnReverseButtonClick
Yeah
That way it won't execute both at once
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;
}
}
}
God damn, it actually works.
I've been at this bug for nearly 3 hours now
thank you, honestly
Welcome, bye!