So long story short, my dragon in my game has the animations to do a fireball and a bite attack. I eventually want both, but for now I need to get the fireball one working as it will be important for a puzzle in the game’s 7th level.
I need to have the character enter into the “shooting fireball” animation as the fireball charges for a second and then it will automatically release to hit wherever she is aiming at. I have fireball particle systems made with Niagara, but I have no idea how to put these together to make a functioning fireball attack.
On top of that, I need to know how to get up a widget with the main HUD to allow for clicking on one of four buttons to change the element of this fireball into an ice, lightning, and stone ball attack. That part should be fairly easily since I think can just add “press alt to show cursor” and allow the player to click the element buttons while the game is active, setting a variable float to 1,2,3 or 4 and change the particle used based on that. Again though, idk how to set that up to work that way with the particle attack.
Can someone help me figure out how to tie a fireball to RMB like what I mentioned? LMB will be the bite attack. I imagine knowing how to do the fireball will pretty much tell me how to do the bite too since that one is less complicated.
First: Make the Niagara particle system node targeted to the mouth bone (or socket) of your dragon skeleton.
Second: Add a “start fire” event tag to the animation for the fire breathing.
Third: listen for that animation event in the character, and when you get it, turn on the Niagara emitter. Or, if you use one-shot particle systems, spawn the effect attached at the location of the mouth bone/socket.
Fourth: In your player controller, bind RMB down to call your character/pawn to set “is fireball attacking” as a variable
Fifth: In your animation blueprint, read the “is fireball attacking” variable, and transition into playing the fireball animation when it’s set
Sixth: At the end of the is fireball attacking animation, send another event (or listen to animation end) that is listened by the character and clears the “is attacking” flag
Oooh not sure I understand all that entirely lol. I will try to put something together based on what I think that means and see if it works. If not, I reckon I’ll have a screenshot of my failed attempt soon lol.
Sounds simple enough, but I will likely mess it up somehow. I understand the attaching to the skeleton though, I figured that was prolly the easiest part since I have the particle systema and animation for the fireball already. The rest I don’t understand too well, but will do what I can and see if I set it up right. I’m pretty new to the Unreal side of game dev tbh. Ty!
So I got the particle system “spawner” attached to the dragon skeleton and when enabled it will fire once since it only spawns a one shot system I think. Not really sure but if that won’t do the one fireball then that’s fine I can just put the system itself there.
I added a “start fire” notify to the shoot fireball animation. Not sure if that’s what you meant by event tag, but if so that’s on it now.
Third one I don’t really understand. How do I make it listen for that animation event? Also wouldn’t I have to call the animation via the anim BP by a boolean for “Is fireball Attacking?” type thing? (totally just read that in step 5 haha, nvm on this bit, in terms of the anim bp part)
I know how to do the binding RMB to attack and setting the “is fireball attacking” to true on there though. I just don’t fully understand step 3. So basically just step 3 and 6 confuse me. The rest I think I got down.
Sorry, I was using the wrong word, I mean the animation notify:
You define these on the animation and can bind these to events in your animation blueprint, and from there you can access them or call into your owner character to update it if needed.
Note that it matches up based on the skeleton used in the animation blueprint, and the skeleton targeted by the animation, so if those don’t match, your animation blueprint may not see them as possible notifies.
There are some samples in the unreal starter content that do this for Jump, for example, to always jump when the foot lands.
Ok so it was the notify thing then, gotcha. I added one of those about midway through the animation since that’s when the dragon’s mouth is open. Figured that’s prolly the best spot to have it spawn the particle system.
So how would I actually call them in the anim bp? This isn’t something I’m familiar with. Could be the terminology again, but I’m not understand how to make it “see” the notify and then actually enable the spawner.
I can say though the skeleton and anim bp both match so there’s that at least. I’ve actually struggled with setting up the anim bp lol and am sure mine is wrong on a few ways considering a double jump often launches the dragon very high randomly when it shouldn’t. Also her animations freeze into a fall anim when bumping into stuff and idk how to fix that one either.
Edit: So I’ve tried to figure this out lol. What I have is the animation not playing…the fireball spawns but doesn’t vanish after x seconds or when it hits something, and it doesn’t leave it’s spawned location but remains attached to the socket.
Here’s the current setup on the player controller, how I thought you meant at least. Not sure why the animation for the attack isn’t playing though nor how to get that properly set up. I think my entire anim BP is screwed a bit.
Not sure if I’m even on the right track here but yeah. This is essentially how the spawn thing “launches” the fireball so figured it would at least do that but it doesn’t. Impact Power is 1k, Level 1, and the Gravity is set to not. When it’s not ready it waits a few seconds then enables ready which allows it to spawn the fireball, but as mentioned above and shown in the picture it just stays there when spawned. The “animation” you see in the picture isn’t the fireball one, it’s one of her idles which is yawning, almost same pose but slightly different lol. Any idea how to get this working the rest of the way or what I’ve done wrong?
Hm, well I figured out the melting door Part at least lol. I can run that fireball into it and it’ll melt so that part’s done. I still gotta get the animation for shooting the fireball as well as it actually moving away from the player in the direction they shot it though. But at least one part is completed and works since it calls for the BP of the fireball itself to overlap. I also figured out the swapping of the elements easily enough so I got that part done too.
You don’t directly spawn things from the animation blueprint, it needs to be done in the Character (or PlayerController, perhaps.)
If I remember correctly, you’d create an Event Dispatcher in the Animation Blueprint, call it something like “spawn fireball,” and then in Begin Play, you bind the event dispatcher from the blueprint into some event that actually does what you need in the Character.
To do that, you’ll need to get the animation instance of the character mesh, and cast it to your blueprint class, so you can find the event dispatcher. Again, if I remember correctly – I made a thing like that a few years ago, but I forget the exact details.
… I dug up an example in the Amplify Animation Pack, and added an event dispatcher to it, so, yes, it seems I remember right:
xD I’ve never dealt with that thing before tbh. I did however get some form of it working o.o can fire off a fireball but the character won’t play the animation. Something is wrong with how it’s done in the anim bp I think. Like, that’s basically all that’s needed now is just making the dragon play the animation.
Also lol how I got it working is prolly the most chaotic way of doing it but I have tested it a bunch in various situations and it seems to always do what it’s supposed to so I guess it’s working idk. But yeah the animation won’t transition to the “firebreath” one to make it more believable that she’s shooting a fireball. A friend of mine said just have the controller call a montage for it but that didn’t work either. Blending the “attack overlay” state machine with the default one also doesn’t seem to do anything. I don’t understand much with the anim bp stuff but am learning slowly. So I’m not really sure how to even make a setup for her to attack both melee or the fireball method. That’s all that’s left though, just the animation to play.