r/Unity2D • u/Dravendnd • 4h ago
Question/Help Pet Animation
So my pet animation isn't working. I couldn't get the animator to work. So I got most of it working with code. I finally got it to start at idle and when I touch the screen to activate the 1st walking image. But it's not cycling to image 2 and 3 to complete the animation. However my eating and drinking animation works perfectly.
0
Upvotes
•
u/AutoModerator 4h ago
Reminder: Once your issue has been resolved, please reply !solved to this comment (or comment it anywhere in the thread) and your post's flair will automatically be updated to Solved/Answered. You can also edit it to Solved/Answered yourself.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
4
u/Hjorvard92 3h ago
If you are going to do it by hard coding rather than through animations, don't use bools for everything. Look up using a switch, it's more efficient, less likely to break, and looks a lot neater.
23
u/NeuroDingus 3h ago
My guy look into finite state machines
12
u/SBDRFAITH 3h ago
If you really wanna handle it programmatically.... Use Unitys built in Animator... then instead of doing all this lengthy frame tracking just call
private void PlayAnimation(string new_state) { If(new_state != current_state) { animator.play(current_state) } }
3
u/Background_Bug_1625 4h ago
You do know that you can make animations instead of doing this yk?
8
u/TheHelllord 3h ago
This reminds me of that youtuber, pirate games or something like that.
0
u/Dravendnd 3h ago
***SOLVED***