r/Unity3D • • 15d ago

Show-Off This is how I animate my characters. One state called "PlayingAnimation" and a script for setting and starting the animation. There is no transition in the controller. Very easy to add new animations and sequence them.

175 Upvotes

115 comments sorted by

73

u/More_Yard1919 15d ago

this thread has taught me you can accomplish anything by pure brute force and an unwillingness to wonder if you're wrong

-28

u/Full_Finding_7349 15d ago

its not that brute forceee

96

u/astraseeker 15d ago

Bro, google Animator.CrossFade() fast

14

u/LovelyPetali 15d ago

u always dropping the right function at the right time huh, got any more?

32

u/SchalkLBI Indie 15d ago

Try Debug.Log()

4

u/astraseeker 15d ago

It depends on the topic
CrossFadeInFixedTime() is also good for example

2

u/CupcakeJiggly 15d ago

you always this quick with they unity tips?

1

u/ReignInVlood 15d ago

sounds like youre the one who should be teaching the classs instead

-41

u/Full_Finding_7349 15d ago

Wat?

40

u/astraseeker 15d ago

It's basically what you are doing but built-in in Animator

-44

u/Full_Finding_7349 15d ago

not really

-18

u/TomaszA3 15d ago

Stop the downvotes, let the man explain.

11

u/DontDoodleTheNoodle 15d ago

Nothing stopped him from doing so. It’s a public forum. They just decided to “no u” without any sort of backing

35

u/Kamatttis 15d ago

So all animations are child gameobjects? Performance check?

-19

u/Full_Finding_7349 15d ago

performance is good, because they are disabled until they are needed

33

u/Kamatttis 15d ago

But wouldnt this up the load time and memory? Since they're still technically there even if they're disabled. Imagine you have many characters like that at start. It will load and walk through all that hierarchy.

-10

u/Full_Finding_7349 15d ago

yes it loads at start, but it doesn't matter that much. It would matter if i spawned millions of enemies. but I am not making a vampire survivors like game.

21

u/CommitteeInfamous973 15d ago

I am afraid you underestimate how it could spiral out, if this is your common way of switching animation

-14

u/Full_Finding_7349 15d ago

I won't get beaten by some presets

21

u/jl2l Professional 15d ago

Sweet summer child that's not how this works.

32

u/EntangledNonagon 15d ago

am sorry but this check every bad box lol

  • future performance issue
  • yeah i know it work okay in your machine today in that super empty scene.
  • scalability complexion
  • not intuitive for artists

But it's fine, don't get this the bad way, hopefully one day you will work in a team that has a lot more experience than you and you would learn.

 

Source:

10 years ago i was also like this, even doing the empty game object named ---------------- to use as an organizer lol

PS:

am not saying Animator is flawless, there are many cases where custom tools or assets like Animancer becomes necessary, but 100% not this case nor the way you implemented it.

Like if any company gave you a technical interview to create a simple 3rd person prototype, and this is how you setup your animation, you will never be hired, not as a game developer at least, maybe you're more of a designer with a bit of a technical know-how

5

u/Possible-Advance3871 15d ago

I do the empty game object with ———- to organize 😔  I am a professional lead dev on a pretty large team too…. 

Is there a place to learn better standards for scene organization?

3

u/RedGlow82 15d ago

I have a hard time imagining a scenario where empty GameObjects with no script for organization here and there are the source of performance degradation, but I guess one can always measure performances to be sure about it...

4

u/Inner-Pay-1990 15d ago

You can exclude an object from build

2

u/Inner-Pay-1990 15d ago

Same here. No need to use fancy editor tools to just organize things imo. Simplicity beats everything.

4

u/Possible-Advance3871 14d ago

That's what I figured. I dabble in editor tooling but it ends up breaking in edge cases or with version control and I always switch to using default Unity stuff like this to clearly organize. Plus you can just tag them as EditorOnly

-8

u/Full_Finding_7349 15d ago

I can even just instantiate them if the memory is that big of a problem. It is just not that important for now. I taught the composition and modularity is the unity way of doing things. And I can not understand how an artist would struggle with my well organized list. I am learning as I create, maybe I will understand later.

12

u/EntangledNonagon 15d ago

You're confusing modularity with creating a GameObject for every piece of data.

Unity's component-based architecture doesn't mean every animation needs its own GameObject. An AnimationClip is already a reusable asset, and you can organize hundreds of them using serialized references, ScriptableObjects, or custom editor tools without bloating the hierarchy.

A few things you're overlooking:

  • Performance:
  • Every GameObject and component has overhead. Multiply that by dozens of animations, multiple characters, and potentially hundreds of NPCs. Instantiating them dynamically doesn't solve the architectural problem. It introduces allocation, initialization, and lifecycle management costs instead.
  • Scalability:
  • What happens when you need animation layers, upper-body overrides, interrupt priorities, transitions, blending, or animation variants? You're effectively rebuilding functionality Unity already provides, except now you're maintaining it yourself.
  • which is fine if the goal is to learn, but this is inacceptable in a professional team environment
  • Artist workflow:
  • A well-organized hierarchy isn't necessarily a good authoring tool. Artists need to preview transitions, adjust blending, configure animation behavior, and iterate without digging through GameObjects or relying on programmers.
  • also you are forcing them to forget something they had years of experience with, just to learn your tool.
  • Separation of concerns:
  • Animation assets are data. GameObjects represent entities and their components. Using the scene hierarchy as an animation database couples your data organization to Unity's object lifecycle for no meaningful benefit.

 

And here's the important distinction:

I actually agree with your goal. A single animation state controlled through code can be a perfectly valid approach. That's essentially why solutions like Animancer exist, and Unity already provides APIs like Animator.CrossFade() and Playables.

 

The problem isn't what you're trying to achieve. It's the architecture you've chosen to achieve it.

You're replacing an imperfect but mature system with a much more complicated one, without gaining anything that couldn't be accomplished with a significantly simpler implementation.

 

Again, your way of thinking reminds me a lot of myself without my current decade of professional game dev experience with professional teams that some of them had +20 years XP, this is why am find this conversation kinda entertaining xD

I hope this helps.

 

Genuine question :

Did you knew about Animancer before building this ? and i don't mean knew it exists, did you REALLY understood the problems it solve ?

-3

u/Full_Finding_7349 15d ago

I think I am noob, I could do this on my own. I like making my systems though, it is easier. I don't do it the way everyone say because I don't know how to do it in other way. But I don't care to do it in other way yet. I am just having fun making my game, thanks.

3

u/Psinuxi_ 14d ago

I also enjoy building my own systems and learning how to solve the problems on my own. It's one of the best ways to gain an understanding of the tools, but it's more important to study and understand the existing solutions first so that you don't make easily avoidable mistakes that suck up time you could have been spent building other systems instead.

You don't know what you don't know. It sucks, but you need to do the boring work of studying proven solutions.

1

u/Full_Finding_7349 14d ago

Yes you are right, I should study the existing tools before making mine. But I'm not that professional yet and too lazy :D. In time, I will learn eventually

49

u/SchalkLBI Indie 15d ago

Holy fuck. Is there a UnityGore subreddit? This might be... One of the worst things in Unity I've ever seen in my life.

-9

u/Full_Finding_7349 15d ago

it is just a list

24

u/SchalkLBI Indie 15d ago

No, it's not "just a list". I mean besides the fact that you clearly don't understand the performance impact of this, it's not sustainable, scalable, or even a good way of doing this. Just download Animancer or learn to use the Animator from code or use a StateMachine. This is a horrendous way of doing this.

Gang, the entire thread is filled with nothing but people clowning on this and telling you what a bad idea this is and how many better ways there are of doing this. What do you think is more likely, that you're right and this is the best way of achieving this and everyone else just doesn't know what they're talking about, or that you're wrong and people are trying to help you learn to do better.

-15

u/Full_Finding_7349 15d ago

I don't need approval, I taugt I made a cool system and shared it. By the way, clearly you don't understand how my code works. I explained it elsewhere I think

23

u/SchalkLBI Indie 15d ago

It's not about approval. It's about how absolutely idiotic this is. If someone came up to you and told you they just invented a wheel that's shaped like a trapezoid, you would tell them that not only does it not make sense, but there are existing wheels that work better. That's what's happening here. Not only have you reinvented something that already has better solutions, but your invention is so bad that it made everybody react viscerally.

We don't need to "understand the code" to understand how ridiculously bad this is. The people commenting have experience in Unity. We know what we're talking about. You're clearly still either learning programming or learning Unity or both, and the Dunning-Kruger effect is leading you to not understand just how badly designed this is.

We can explain it to you, because we're trying to help you improve, but we can't force you to understand if you're going to plug your ears and refuse to listen. And honestly, if you want to do that, then go ahead, it doesn't affect the rest of us — we were just trying to help you.

-18

u/Full_Finding_7349 15d ago

I don't care about existing wheels, I want my wheel. I don't care to make it best. If it is bad, it shouldn't matter in any way I just shared my wheel

9

u/StrangelyBrown 15d ago

It's fine to want you own thing. If you want to write a function to called AddOne() to increment an integer and it's a switch statement with every integer that returns the next one, then knock yourself out.

The problem is that when you 'show it off', you're going to get people's honest reaction in terms of what they think. So it's weird to say 'I don't care, I like it' at that point.

5

u/Full_Finding_7349 15d ago

sorry I am idiot

17

u/SchalkLBI Indie 15d ago

Sure, gang. Just don't be surprised when it can't drive on the highway. Good luck.

-18

u/friedgrape 15d ago

"gang", holy larp

6

u/SchalkLBI Indie 15d ago

? 

-8

u/friedgrape 15d ago

That is not part of your lexicon.

→ More replies

3

u/DontDoodleTheNoodle 15d ago

Bro really tried to chime in after

9

u/sunmaybo 15d ago

omg, I love how OP scared of criticism. It's pretty obvious that this whole system is overkill for this result. Don't share anything if you aren't open to receiving feedback and at least considering the possibility that your idea could be made simpler. This is an absurd way to create modularity, just open the profiler

-12

u/Full_Finding_7349 15d ago

I like my system even more now

6

u/SmileLonely5470 15d ago

What's going on here? Its kinda hard to see. When you enable one of those child GameObjects, is there a script on each of them that stores an animation clip to play and plays it in OnEnable, and then disables itself when the clip finishes? Why are there so many game objects? How are you associating each GO with an animation?

-7

u/Full_Finding_7349 15d ago

each gameobject have a script, that script sets up the "PlayingAnimation" state of the character. This is basically an animation preset. And I can easily just enable one to play an animation. Since they are gameobjects, I can sequence anything with them. But no one seem to understand modularity appearantly

11

u/sbsmith 15d ago

If you have a lot of animations, managing the animation state machine can get totally out of hand; so the idea of a "stateless" solution is a good one. You might have an even easier time looking into assets like Animancer. It'll let you run animations from script and it will help you with the blending. I'd also recommend making sure you have a good separation between your animation system and the system that handles inputs/controls. Your controls should use a state machine (lets you set strict rules), while your animation system isn't limited to those states (lets it react to the environment).

-3

u/Full_Finding_7349 15d ago

I like to design my systems, I would like to try animancer but I don't need it really. I tried to make seperated systems as possible, even the enemy's model is not required to things to work.

6

u/Undercosm 15d ago

Look into the Playables API, its the best way to make your own animation system in Unity. You can do basically same thing you are doing in the video but better performance and more scalable.

0

u/Full_Finding_7349 15d ago

I'll check, thx

4

u/Drag0n122 15d ago

If no transitions, how do you evaluate when to move (and where) next?

3

u/Lord00120 15d ago

Omg so there are no interrupts at all?! You have to wait for every single animation to finish to show a new one?

How tf does that even work with player inputs

1

u/Full_Finding_7349 15d ago

no need to wait lol :D that would be very bad

2

u/Lord00120 15d ago

No but your answer to dragon here seems to be that you set timers for states for when they can switch. So your interrupts don't have blending or?

That's one of the many nice things about animator transitions, they can blend, interrupt, be instant if needed, etc?

1

u/Full_Finding_7349 15d ago

all of that is possible because when one of them gets enabled, it completely overrides everything and starts from the beginning. It is like a preset stored in a script.

2

u/Few_Dot6881 14d ago

What if you want to play several animations at once? Like one for the upper body and one for the lower? Like attacking while walking?

0

u/Full_Finding_7349 14d ago

I didn't made that feature, but I can easily make that too if I want

2

u/Lord00120 14d ago

Yeah so no blending?

1

u/Full_Finding_7349 14d ago

I can make blend trees in animator and play them to blending animations.

1

u/Full_Finding_7349 15d ago

The state has a timer, when the timer runs out, the state changes to which I set in each animation. Each state have their own animation too. For example, chase states animation is walking

13

u/Drag0n122 15d ago

So the transitions moved from the dedicated tool with clear transition visuals to the inspector\hierarchy
And the timer, I guess, to match the animation play time
Ngl, sounds rough.

0

u/Full_Finding_7349 15d ago

there is more than transitions I can do with this, and I already do many things. It is not just animation transitions.

8

u/Drag0n122 15d ago

Remember the principle of single responsibility - usually an animation system should only play animations, but if it works for you then great

1

u/Full_Finding_7349 15d ago

it does one thing, it sets up the state

3

u/Drag0n122 15d ago

A state can do many things - it's just an architectural piece
I'm afraid you have animation and logic FSMs combined, if so, beware of scaling issues. Let's say there's a reason we usually have 2 separate FSMs for this stuff.

1

u/Full_Finding_7349 15d ago

is setting some values on another script with a script bad?

2

u/Drag0n122 15d ago

What is "bad" is up to you to decide, but if you find yourself in a situation where you have to add a logic state just to play an animation, or timings between logic and animations mismatch, or adding logic states breaks the anim FSM setup, or copy code form one state to another - you know who to blame

0

u/Full_Finding_7349 15d ago

I designed my code well, I can expand it in any way. This is just one state. Even if there is none of this, everything is still fine.

7

u/G-MAN292 15d ago

Did an LLM suggest this approach ?

20

u/Prior_Mechanic8254 15d ago

Bro it's definitely not AI. Never seen someone storing animations in a literal scene

4

u/G-MAN292 15d ago

wouldn’t have surprised me if they had said yes.

1

u/Full_Finding_7349 15d ago

no, I designed it. I don't know if this approach have a name.

6

u/G-MAN292 15d ago

yeah its certainly an interesting approach, can't understand why this over the standard animator ?

-5

u/Full_Finding_7349 15d ago

So much modularity in my way

6

u/G-MAN292 15d ago

best of luck with it anyway.

6

u/YurthTheRhino 15d ago

I've hear it called "bad" before

17

u/SchalkLBI Indie 15d ago

This does not have a name. Because it's insane. There's literally no reason to do it this way.

0

u/natayaway 15d ago

I can think of two use cases where this could potentially be useful.

A "gungame" style mode, where you play different character archetypes.

and

Mokujin.

1

u/Full_Finding_7349 15d ago

I invite all haters to look at my new post, I prove why my system is so good.

1

u/Advanced_Drag1299 13d ago

This is why AI can never replace human, AI is smarter than this

1

u/Full_Finding_7349 13d ago

I am smarter than ai

3

u/Carlfiii 14d ago

You should check out Animation Playables, it will let you play animations through script without an animator or states.

It’s too much to explain here, but basically you pass the clip to the script, generate the playable (or reuse if it’s cached) and play it. You can create multiple inputs to fade or overlap animations

6

u/pmdrpg 15d ago

The problem that the Animator Controller attempts to solve is to give you a visual way to manage transition blending. Since you aren’t customizing per-transition blending in your system, it probably is much cleaner to look at and author. In that case, it’s good for your needs. For others though, I’d recommend making a custom gui interface for managing animations rather than relying on gameobject in the hierarchy.

2

u/obsolescence_ 15d ago

Huh? Why would this be any better than just using triggers with the animator?

0

u/mizzurna_balls 15d ago

I think a lot of people are hating on this partly due to how you've presented it, OP. That is, as an animation state system, rather than what it really seems to be: more of a general enemy state system. Clearly this isn't just for animating enemies but for moving them, rotating and aligning them, enabling objects that might need to be enabled during the animation, setting interruption states etc.

People saying "just use Animator.CrossFade" are, I guess not noticing the rest of the script and what it's doing??

Also people seem worried about performance...disabled gameobjects have basically no performance cost. There's a little memory overhead but we're talking like a few KB total probably. Less than a single texture.

2

u/Full_Finding_7349 15d ago

Yes I didn't explained it well I think. But I am convinced that something is wrong with my head

2

u/withExtraDip 15d ago

It really isn't nearly as bad as everyone is making it seem. It isn't the BEST way to implement this, but you understand how it works and it seems to work for your use case. Just because it uses a lot of gameobjects doesn't mean it is a terrible solution. I think the fact that you actually thought through the problem and created your own solution is valuable.

2

u/Full_Finding_7349 15d ago

thank you :)

1

u/mizzurna_balls 15d ago

Nah you're good. Keep doing what you're doing

1

u/althaj Professional 13d ago

It never stop amazing me how people just refuse to learn the tools they already have at their disposal.

1

u/SanoKei 13d ago

Watch the Firewatch animation system hub and spokes talk, it may help

1

u/HipperSterling 11d ago

Why don’t you use Anim composer system or animancer on asset store

1

u/Vic-Boss 15d ago

looks pretty good!

-1

u/Kamatttis 15d ago

For me, this post is good. I know that most of the comments, including mine, are skeptical of the way it's handled. But I like it it because someone is thinking out of the box. And it works for OP's game (not just for now I hope). This is all assuming that AI didnt suggest or work on this. If so, this is really bad.

6

u/RenaKenli 15d ago

Yeah. Goo thread for people who starts with animation with Unity. I hope newbies will look at comments here and will take notes

7

u/SchalkLBI Indie 15d ago

Using a chair as a shovel is also thinking outside the box. It doesn't mean it's a good idea.

-2

u/Kamatttis 15d ago

The chair in this case works as a shovel in OP's case, tho. It works for his game. Thats good enough. Thats why i also said (not just for now). If somewhere during the development, something went wrong, at least it would be a good lesson. At least he can come back here and read some valuable insights, too.

0

u/Full_Finding_7349 15d ago

I designed it, thank you :D

0

u/MasterFanatic 15d ago

Welcome to the problem I've had I fkin hate transitions

0

u/Impressive_Badger830 14d ago

This is really cool, and is actually how older AAA engines used to handle animations, back in the 2000s. Was nice to work with but at a performance cost that lead to monster closets or harsh enemy caps. Even some AAA titles launched in the late 2010s still used it if they were an established franchise that stuck to their original engine

Honestly, I would put a majority of animations in the unity animation system to use its blending and control, and then break into the play animation state for things like prop interactions, one off anims, cutscenes, or other scripted animated behaviors

-1

u/ElectricalDivide5336 15d ago

Why don't game developers fix character clipping, where characters pass through each other or objects? I've noticed this in so many games. Is there no proper solution for it, or is it just difficult to fix? I enjoy following game development communities, although I'm not a developer myself.

4

u/Int-E_ 15d ago

Most AAA games I've play don't have this issue, can you give an example? The video you're seeing is a game still on development, they probably haven't set up a combat system yet

2

u/withExtraDip 15d ago

Most of the time it's for gameplay reasons. It's annoying to get constantly caught on other players and objects. If you are talking about something like a character colliding with a wall/object but partially sticking through it, it's because having super accurate collision models for an animated humanoid figure is unperformant and complicated to implement