Animate like a Programmer

Animate like a Programmer

Tarodev

2 года назад

225,591 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@t33h33studio
@t33h33studio - 20.08.2024 00:45

How much does int hashing improve performance? Lets say we have a robust system for the player so animations for jumping, falling, transitioning, sliding, walk/running, wall running , etc. As your example is, with pixel art specifically. How do you know when int hashing is worth the time investment?

Ответить
@Conradh13
@Conradh13 - 10.08.2024 15:12

Wait... you can just do that????? So I've spent who knows how long checking and rechecking dozens of transitions, adding, removing and moving around bools and triggers when i could have just told it to play the animation and got it working perfectly in 30 seconds??????

Ответить
@ALX3
@ALX3 - 25.07.2024 19:30

Finally found a channel with 0 BS, straight to the point, non-trivial dev advice.
Thank you!

Ответить
@baptm727
@baptm727 - 11.07.2024 20:37

Thank you for sharing this

Ответить
@TheKr0ckeR
@TheKr0ckeR - 01.07.2024 17:56

Thanks a lot. Does it work with multiple layers ?

Ответить
@itsJDarts
@itsJDarts - 26.06.2024 17:25

No way this guy is reading 700 comments

Ответить
@Skybot437
@Skybot437 - 17.06.2024 04:34

Dope. Now I can wipe that spiderweb out of my animator. Thanks!

Ответить
@LA-dm6kj
@LA-dm6kj - 15.05.2024 02:53

Thank you for this video.

Ответить
@jessebensen3569
@jessebensen3569 - 16.04.2024 04:03

You can go a step further and just write your own animation classes. I do it a lot with Images under the Canvas, and I've been thinking of creating a more robust AnimationManager that maintains a list of different animation types that all derive from an abstract base class. Here's a one-off example using a normal Unity C# class/script. The intended usage is to have an object of another class holding a reference to an instance of this class which is attached to a gameObject that also has an image component. That other object uses the reference to set the gameObject holding this animator script active/inactive. This specific design is intended for an object that is always animated when visible.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FlameAnimator : MonoBehaviour
{
private List<Sprite> sprites = new List<Sprite>();
private Image flameImage;
private bool playAnimation;
private static readonly float spriteChangeInterval = 0.07f;

private void Awake()
{
this.sprites.Add(Resources.Load<Sprite>("Flame0"));
this.sprites.Add(Resources.Load<Sprite>("Flame1"));
this.sprites.Add(Resources.Load<Sprite>("Flame2"));
this.sprites.Add(Resources.Load<Sprite>("Flame3"));
this.sprites.Add(Resources.Load<Sprite>("Flame4"));
this.sprites.Add(Resources.Load<Sprite>("Flame5"));
this.sprites.Add(Resources.Load<Sprite>("Flame6"));
this.sprites.Add(Resources.Load<Sprite>("Flame7"));
this.sprites.Add(Resources.Load<Sprite>("Flame8"));
this.flameImage = this.gameObject.GetComponent<Image>();
this.playAnimation = false;
}

private void OnEnable()
{
this.playAnimation = true;
StartCoroutine(AnimationCoroutine());
}

private void OnDisable()
{
this.playAnimation = false;
StopCoroutine(AnimationCoroutine());
this.flameImage.sprite = sprites[0];
}

private IEnumerator AnimationCoroutine()
{
while(this.playAnimation)
{
for (int i = 0; i < sprites.Count; i++)
{
this.flameImage.sprite = this.sprites[i];
yield return new WaitForSeconds(spriteChangeInterval);
}
for (int i = sprites.Count - 1; i >= 0; i--)
{
this.flameImage.sprite = sprites[i];
yield return new WaitForSeconds(spriteChangeInterval);
}
}
}
}

Ответить
@nahuelhemsi
@nahuelhemsi - 15.03.2024 17:52

Keep the good vids, amazing!

Ответить
@CHETANRENUKA
@CHETANRENUKA - 14.03.2024 10:50

😀

Ответить
@getintheoven
@getintheoven - 15.02.2024 09:58

had to come back with a new channel because the game i was working on last year uses your character controller... thank you for existing btw! hope you're overcoming any stress you're dealing with at this current point in time and that this year goes great for you :)

Ответить
@SolChaos-ph7ye
@SolChaos-ph7ye - 12.02.2024 08:55

"That's how you animate like a programmer"
as a programmer, I would say you are seriously gimping yourself animating like this. If you animate this way you missing out on all types of blending, layering and state control. Plus, also as a programmer I greatly appreciate separating animation out of of my code.

Organizing your animation states and using substates, layers, and blendtress will prevent any spiderweb issues once you gain the proper experience.

Ответить
@firstvf
@firstvf - 29.01.2024 06:02

Didn't expect that 2 minutes video could be so useful.. You are genius, thanks!🙂

Ответить
@niuage
@niuage - 23.11.2023 13:29

Very useful, I'm gonna try this method, but for a 3D game.
Just a tiiiiny criticism, because I see this done in so many pieces of code: why try to shorten the var names so much that they become confusing? For instance, "private Animator _anim;". That should be "private Animator animator;", "anim" is confusing since it could also be an Animation. I see things like that done so much, and I wish people named their vars better.

Ответить
@SeniorMatth3w
@SeniorMatth3w - 08.10.2023 12:15

How did u get "bool _landed' variable?

Ответить
@maykefernandesdossantos7374
@maykefernandesdossantos7374 - 02.10.2023 19:56

animation on Unity does suck, but this approach only works for indie devs I guess, it would be the worst idea to have your entire animation on code on a big project, designers have no way to change anything without code changes, and even if you offer an interface for this via inspector it would still be bad, if all you have are developers on the team and a small project mostly maintained by you then I guess this is a viable approach if you like programming, apart from that, not really a practical approach in the end. but good to know about its existence anyways

Ответить
@huseyinakkoc1062
@huseyinakkoc1062 - 27.09.2023 13:25

my animator sometimes gives really long error starts with graps awake .. how can ı fix it? it is fixed when ı restart unity but ı have restart per 30 or 15 minute

Ответить
@KG-id3hk
@KG-id3hk - 13.09.2023 12:20

Honestly, as a programmer, i could deal with the giant frustration of networking and animation. With enough trial and error, things will work!

But for the life of me, i can't make a simple UI that looks pretty.. i just dont understand art 😕 🤷‍♂️

Ответить
@spacesandshark2418
@spacesandshark2418 - 27.08.2023 07:59

Holy shit, is this video really only 2 minutes long? It felt much longer, and I mean that in a good way. A lot of information presented very concisely and intelligently. Thank you.

Ответить
@GiangNguyen-ho5st
@GiangNguyen-ho5st - 23.08.2023 17:24

OMG I thought I was the only one triggered by the lines not being straight in the animator

Ответить
@maxnibler6090
@maxnibler6090 - 26.07.2023 12:26

Im getting into unity with some friends. Im a professional programmer but this is my first real foray into game dev. My friends are all artists so I handle all the code. This channel is everything I want. I can figure out how to do nearly everything from the docs but never really know if Im following good practice. Most tutorials have been worthless because theyre not written for or by programmers. Loving you channel because its exactly what Ive been looking for

Ответить
@mrcroco5121
@mrcroco5121 - 11.07.2023 14:15

this channel is a blessing ..honestly. superb content.

Ответить
@blackestbill7454
@blackestbill7454 - 30.06.2023 03:04

thanks you're amazing

Ответить
@nanomantube
@nanomantube - 30.06.2023 00:17

I'm trying to get out of the Animator window and go this route. Though I'm having a hard time comprehending it, it makes my head hurt.

Ответить
@liquidsword926
@liquidsword926 - 13.06.2023 00:15

I've tried animancer but it doesn't work with mirror networking, sad

Ответить
@technofeeliak
@technofeeliak - 28.05.2023 16:05

Well, I've been working on the graphics for a few years now. I'm going to have to get serious about the controls.
Have you ever generated your graphics via scripts?
That's what I'm doing. They're all 3D meshes. Kind of like SVGs would have been, created dynamically in Flash.

Ответить
@xena-spectrale
@xena-spectrale - 25.05.2023 15:10

This tip is so simple yet so effective. It just pulled me out of a full half-day unity animator nightmare. Thanks Tarodev 💙

Ответить
@jeromeisntdev
@jeromeisntdev - 19.05.2023 06:57

I have a question. How do you set the bools back to false? For example, I'm using when you press the "Attack Button", '_attacking; is set to true. At which point does it become false again? Are you using AnimEvents?

Ответить
@bimokayoba
@bimokayoba - 15.05.2023 18:45

im stuck at the animator for setting the animation settings and code help!
(walk,idle,run,attack,hurt,die,jump(random jump animations)dash....)

Ответить
@hamsterbyte
@hamsterbyte - 09.05.2023 23:54

Animating like a programmer > programming like an animator.

Ответить
@back2back712
@back2back712 - 04.05.2023 08:35

Can you pleaseeeee make a detailed video about animating using scripts

Ответить
@gunhann
@gunhann - 27.04.2023 12:05

I'm relieved that I'm not alone to align horizontally the animator connection lines :D

Ответить
@mattkaiser8984
@mattkaiser8984 - 04.04.2023 07:30

😭 the line… you just touched my heart. That line drove me insane for so long. I hate it.

Ответить
@bluzenkk
@bluzenkk - 03.04.2023 21:28

sometimes.... i despise Unity for having multiple ways of doing animation....
lv 1 use animator in the simplest form...
lv 2 use blend tree and sub state and avatar and overide...
lv 3 use animator behaviour component...
lv 4 use int hash + crossfade...
lv 5 use custom finite state machine pattern...
lv 6 use animation rig for procedural animations...
lv ? use animancer pro...

Ответить
@Zuger_W
@Zuger_W - 02.04.2023 14:39

Great job as always! by the way thanks to you that you made me understand i have OCD

Ответить
@spidermankey1398
@spidermankey1398 - 01.04.2023 00:48

Can someone help me how did he use mirrored sprites for negative x

Ответить
@littleowlgaming-unity-tutorial
@littleowlgaming-unity-tutorial - 30.03.2023 07:47

you read EVERY SINGLE comment eh? .... prove it!

Ответить
@clarkmeyer7211
@clarkmeyer7211 - 23.03.2023 21:15

For people like me that use their own state machine this video is priceless.

Ответить
@clarkmeyer7211
@clarkmeyer7211 - 23.03.2023 21:11

Thank you. You just answered a question of mine. I was trying to find out how you apply a crossfade on an animation on a different layer. didnt realize it was one of the variables you just have to pass in.

Assuming you mean something like in the case of avatar masks where in my case I want to make the hands have a different blend tree to the feet using avatar masks to separate the animations

Ответить
@repsejnworb
@repsejnworb - 21.03.2023 12:10

Taking you up on that last bit and informing you that I like pineapple on pizza.

Ответить
@friendlyeasonorg9255
@friendlyeasonorg9255 - 20.03.2023 15:14

How did you progress in unity? I’m at a point where I’m not sure which direction to progress as I’m still a beginner

Ответить
@williamhiciano394
@williamhiciano394 - 20.03.2023 03:35

this is absolutely awesome did not know about this, thanks !

Ответить
@UncleDavid
@UncleDavid - 19.03.2023 22:48

I’m rewriting all this in ts 😭

Ответить
@NazmulHussain786
@NazmulHussain786 - 16.03.2023 18:34

Sir your tutorials are absolutely amazing for beginner devs like me. Sir, just one request your tutorials are very paced. Please go slow. Also I have seen most of your videos. I would request you to make a tutorial for games to run on Android mobiles, their optimization and all the necessary stuffs. You are a life saver indeed!!!

Ответить
@Ricochetaglet
@Ricochetaglet - 16.03.2023 17:15

This is top tier stuff! Wow! Thanks for this bite sized powerhouse! 💪🏿🦾

Ответить
@kazvtuber
@kazvtuber - 15.03.2023 00:55

played your intro at 100% volume and it made my cat jump on my chest and it hurted
??

Ответить
@folashocky2735
@folashocky2735 - 26.02.2023 05:06

How did you get the line to appear behind the character when moving him?

Ответить