So how should I organize/have multiple animations in unreal? What is the best way of doing this? (Before anyone would say this, I googled and checked a few yt videos, but I need a bit more explanation :D)
Currently I have the base movement animations, run and walk (+ jump), what should I do if I want to add attack animations?
For example I would have a basic attack animation, now I should do ALL the animations again with the attack animation? Then if I want to have another type of attack animation I should redo all animations with the second type of animation? Like if I have attack_1 animation, then I should make movement, jump, run, etc etc with that attack_1 animation as well? This sounds WAY too much work, unreasonably too much (because I want to add more characters later, atleast 10, they would need to have separate animations as well?)
I saw that you can blend in animations based on the skeleton bones (Layered Blend per bone), but couldnt figure it out how to connect the animations precisely (had an attackIdle and an attack animation, the idea was that to cache the base walking/running animation and use the spine bone to blend the attackIdleand attack animations together, the problem was that the attack animation was not playing exactly how it should have (the “slash” movement of the attack was just half or less then it should be).
You’re totally on the right track with the blending animations based on the spine! It sounds like maybe the blend-out speed is too high, or the weights on the Layered Blend per Bone need to be adjusted. Typically it can go .2, .4, .6/.8 depending, or .1, .3, .5, .7 etc if it’s four spine bones. It can vary according to your needs!
Animation can be granular to set up perfectly, but just take solace that once you get the hang of certain things (Layered Blend per Bone is a big one!) it opens up a TON of possibilities!
I tried setting some blend weights on both (blend weights left and blend depth on right), but it seems like it didnt do too much, tried 0.2, 0, -1, 2 and higher numbers like 99. I read somewhere that those values should be the other bones’ number, like 3 would be to include 3 other fingers on a hand or something like that.
No, this is how animations were done in very old game engines. These days we blend animations. Animations can be blend by mixing one with another, or by picking an animation for part of the animation skeleton’s bone hierarchy and an animation for the remaining part. There is also a type of blend which allows you to blend from state A to B in a single animation based on parameters. Think of a walk > run cycle based on 1 animation where a float parameter “speed” interpolates from walk to run.
Unreal Engine comes with animation blueprints. Those are files were you blend animations by logic, bone, IK, or those blend nodes taking input parameters. There you can also use state machines. State Machines are useful when you want your character to be able to transition from one state to another (idle to run, run to jump, jump to fall, fall to run).
So instead of having to make a million of complete animations like we did 20 years ago you can now have one blend to make your character point a rifle up down and sideways, one running animation, one shooting animation, and blend them to a whole.
Lastly, you can if you want still play a simple “complete” animation, those are called animation montages. They certainly have their uses but they don’t provide much dynamic control.
If you need a fine example, take a look at the free plugin Advanced Locomotion System, or its c++ github repo.
Thats why I asked, because it seemed way too much work, like, its 2023, there must be a better way then doing every single animation all over again. And there is :D.
Thanks for the explanation! I’m already using animation blueprints, state machines and stuff like that, but dont know way too much about them.
I know that you can set up animations and their transitions between them in the state machine, I started there with enum that checks which animation should be played. But currently I’m having a few bool values from C++ that checks if the player holds a weapon and if it attacks, if they are true then it plays an animation inside the animation blueprint. (An anim montage to be precise).
Is there a better way of playing animations on click or something, than using montages? It seems hardcoded to me to add an if statement then if it is true play the montage. It seems way cleaner and dynamic inside the state machine, is it possible to do it there? And how should I set up the weights to play the full animation?
There is, but it is a lot more complex to set up. You’d be making use of the state machines for very little details such as transitioning from holding a rifle, to “trying to shoot” which results either in shooting or reloading. Then shooting could transition to a success > back to holding position, or a jam. Optimally the state machine simply reads bools from the rifle and character to decide its transitions in the state machine and would then provide feedback through events (when a state is entered / left etc.) You see that while this does provide you with a high level of control, it is about 300 times more complex than playing a montage.
Got it, do you have any idea how could I set up the weights, if I want to play two montages, and blend those two anim montages to the walking/running animation?
For example the attackIdle (the first animation) is played above the spine, the character just holds the weapon in an idle state. Blend weight is set to 1, tried a few values but it doesnt change anything. Currently it holds the weapon, but not exactly how the animation should.
It’s been a while since I worked on animation, I believe there might be a node / slot specialized for montages but I honestly don’t remember. I think the ALS (Advanced Locomotion System plugin) does it. You might be looking for an animation slot.
Raises the question if an animation is ever / always played fully when transitioning, because I remember seeing some video on youtube where someone explained that if you put an event right at the start or end of animation it does not always fire because of blending / transitioning. It makes sense, just something to keep in mind. Sounds a bit fragile but I haven’t worked with animation enough to be able to tell if it is a serious issue. Possibly you’d have to somehow enter the montage without a blend in some situations?
I have tried it without the blending animations (inside anim montage), and it looks like that now the “weapon holding” part is accurate, but now it doesnt blend, and I think it still doesnt extend to the part it should to when it plays the attack animation.
I’m thinking of that maybe the problem is that I’m using a single anim montage to play an animation that should be looped, the attack idle animation, but it looks like that it loops, so I dont know.
ALS uses the animation montage for playing a “roll” and “mantle” (climbing) action, Possibly you can see there how they handle the transition well. For anything else they use blends. There are quite a few things that can go wrong currently.
Worth noting here that you should be using “mesh space rotation blend” in your layered blend per bone if you want this to work correctly. One thing that can happen is if you’ve eased your animation in from, say, pelvis to the top of the spine, now the “root” positions of the arm bones are not where the attack animation expects them to be. Mesh Space blending will attempt to correct this by trying to rotate blended bones to where the underlying animation wants them. This still doesn’t always look correct, but it works better than using local space.
If you have a lot of attack animations, I DEFINITELY recommend montages. In fact, what I actually recommend is the BP node “play slot animation as dynamic montage” and a DataTable; you can write a function that calls an attack animation by name (based on whatever conditions you want; position in combo, is crouched, weapon equipped, and so on), and use the DataTable to look up the relevant AnimSequence and blend values and play those using PlaySlotAnimAsDynamicMontage. Basically this turns a series of anim assets into AnimMontages without you having to make a unique Montage asset for each one.
This may be overkill for your project, it depends on how many attack animations you plan to implement whether creating unique Montage assets is too much trouble.
And look up the name as datatable row name? In that case the better option would be to have a single datatable row for you character containing the animations not by string reference but by Soft Pointer.
The DataTableRow reads a struct for setup and you can configure it to take AnimSequence references directly. I guess you could use a soft object reference to the anim sequence but if I’m understanding the use case for that, it doesn’t seem helpful, since there’s no reason you’d need to call the reference to the animation without also loading the animation anyway, no?
Soft pointers are direct references to assets. Passing references around is much less fragile than strings. Because they are “soft” you won’t ever load the classes into memory just by referencing them. Meaning that if you have a switch which returns an animation based on a condition, or a datatable listing a bunch of animations you pick 1 from, you only load that asset into memory (after calling LoadSynchronous on the ref or doing it async). Very useful.
Edit* Long story short if the references are not “soft” (blue in the editor) but “hard” (purple) you are filling the memory with things you don’t need. So normally you’d already be soft pointers everywhere and can just pass those around instead of strings.
Oh, definitely, but that’s what I’m doing. You don’t need to specify strings in the DataTable
you are filling the memory with things you don’t need
Interesting… though I wonder about the performance impact with attack animations. I mean a data table just existing in the file structure doesn’t require every asset associated with it to load on start, does it? I certainly don’t see any meaningful performance impact as I add more animations to the table. I can understand why that would be useful if you needed to access things you weren’t loading right away (I typically see SoftObject used for things like asynchronous load, at least where it’s been explained) but a table that calls an animation must necessarily also load that animation if it’s going to be used for animation-playing. It sounds like what you’re saying is EVERY LINE in the data table is having every associated asset loaded into memory on startup…? That can’t possibly be how DataTables are built, can it? Sure, once I call the specific DataTableRow and get the AnimSequence object from it, the engine is loading it into memory, but that was gonna be necessary ANYWAY because I need to do that to play it.
Also, this is getting off-topic from the original post. My apologies to @Nechalon.