I know my question is quite broad but I really really need some help since this is putting a wedge in my first project.
I know close to nothing about animations, most I can do is setting up some blend spaces, doing some basic state machines in the animation blueprint and stuff like “if variable X is true, play this animation”.
My issue now is that, as I keep adding new logic to my gameplay, I don’t know how to mesh it with the animations. For example, I have a method called whenever my character uses an item (aptly called, you guessed it, UseItem). Now whenever UseItem is called, a specific animation should be played - is it a healing item? well play the whole “patching yourself up” with some bandages - but this is where my little knowledge of animations comes in. UseItem returns true if the item has been consumed, false otherwise (maybe you’re already fully healed, so the UseItem returns false because you can’t use the bandages) but what if my character is interrupted DURING the animation? I’m healing myself, I get hit, I should now stop the animation; and UseItem should now return FALSE, even if, by all accounts, the game should return TRUE because the item should and can be used. And even if I’m not interrupted during the animation, I can’t just outright have UseItem return TRUE, because that would also call the Destroy to my item.
Now I made a very long winded example here, but the point I want to get across is that, until I have the time and find the adequate learning resources for animation, I need at least a very broad definition/explanation on how to make my methods and game logics ready to be tied with animations that will be later implemented. The UseItem is just one example, but I also have a “Hide” method that makes the player hide himself inside small places. But I can be interrupted there too, maybe even killed in the process of hiding myself, and I can’t have a game over screen appear while still watching the character in the process of hiding himself inside a hole.
I hope I’ve given the idea here, 'cause my fear right now is writing 1k more lines of code only to then realize I have to rework everything because it simply can’t gel together with the animation blueprint
@kn0bbulo,
I think I understand your issue. Say you have the states you want actions to be allowed to happen to the player in - Start, During, and Finish. You can create these functions to act like Event Handlers, calling the beginning of the animation, checking for attacks, then finally applying the desired status effect. You may also want to have simple boolean variables that can be switched on/off for these effects, especially for the during, that way you can reference something like an isUsing variable.
I will also recommend starting to get a bit of a base for the animations down, due to the fear you’ve described too. It’s definitely overwhelming at first, but gets drastically easier the more you do it and put effort towards it.
I hope this can help!
-Zen
Perhaps in the case on the healing item you could play the healing animation and at the end of the animation add a notify that could be linked to an event, then only once the animation completes it would heal the player and use the item.
On interrupt it would stop the healing animation, hence it does not get to the heal action notify at the end and does not trigger the linked action.
So, just to have a rough idea, it’d be something like
Player calls UseItem on ItemObject
UseItem goes:
bool UseItem()
{
isBeingUsed = true;
PlayAnimation();
if(AwaitResponse())
{
// do whatever this item should do (healing, flossing the teeth, exploding)
return true;
}
else
return false;
}
bool AwaitResponse()
{
//Register to Event Dispatch coming from AnimBP called when animation is finished
//Register to Event Dispatch coming from my HealthComponent that registers if damage is received
if(AnimBP dispatches the animation completion)
{
isBeingUsed = false;
return true;
}
if(HealthComponent dispatches damage received)
{
isBeingUsed = false;
return false;
}
//As for the AnimBP
When isBeingUsed == true -> start animation
I doubt I’m even close to the right way to approach this, I have no idea how it would even work to put this “AwaitResponse” to work since I think it’d basically lock my entire character for the whole duration of the animation.
As for learning and start learning animation fast, I tried but I haven’t found a decent course online. Most videos on youtube only cover what I already know (AnimBP and pretty much just setting up the locomotion) and there’s nothing on Udemy either, which has left me quite speechless
I thought of that but I kind of need the UseItem method to return me the boolean value (usage completed/usage failed) since it’s called by an InventoryComponent attached to the character, which would in turn update the inventory status.
If I detach the logic (UseItem() and HasBeenUsed() as the event called by the item) that would probably (big PROBABLY here, I’m a newbie after all) mean that my usable items would need to know the internal logic of the inventory because now they can call the event HasBeenUsed, but when the Inventory is notified, it needs to know which item has been used (which index of the inventory array, was it an equipped item like a weapon or was it an item used from the UI widget? is it a normal item or an upgrade, which is stored into another array?) and I’m afraid the only way to do this is if I put these information inside the UsableObject class itself and then pass them over with HasBeenUsed().
I’m doing my best to keep the logic as clean as possible and this definitely would go against that.
Of course this is assuming that what I described is what you’re proposing
@kn0bbulo
it would probably help if you broke these up a bit, but your AwaitResponse is coming close for sure. Breaking them up would help with what you’re thinking of as the delay. You would want a function that could be referenced by your AnimBP, and a function in Tick that is similar to AwaitResponse, but for each flag you decide to throw, a “setter”. - your first if statement seems pretty good though.
bool AwaitResponse()
if (AnimBP isBeingUsed && damage received){
// play interrupted animation
return false;
}
Having a response come from the Items themselves is also a good way to go.
I hope this can help more!
-Zen
So far Epic’s learning hub has been what I’ve followed to try and learn a bit about animation, but it’s honestly a disorganized mess :,)
The other one, CG spectrum, looks promising, but it’s tremendously pricy for right now. It’s more than a month salary for 9 months. But I’ll probably check it out if I manage to get a better paid job
@kn0bbulo
Honestly, I understand the grievance, looking for new class/tutorials for skills that are quality are always very hard. I’ve been scrounging over Youtube a bit, and it seems like there are a few of the Library’s videos on there as well, and I’m sure the related videos are sure to have much more content for you to watch.
Here’s another one that I found:
I hope some of this can help you out, let me know if you need more help!
-Zen