Spawning a object during animation

Okay, I have absolutely no idea as to what I’m doing :(.


I added the weapon mesh to my character Blueprint & made it invisible, afterwards I then tried to attach it my character’s “hand” via the Animation Notify I created previously, but to no success. I just don’t have enough knowledge of Blueprint’s inner workings to make thing work by myself without a step-by-step tutorial, none of which I’ve been able to find during my past searches on the Internet.

You said to call a custom event but I don’t even know what a event is, let alone how to make a custom one. Looking up the term on Unreal Engine 4’s documentation page gives description:

Unfortunately, didn’t help clarify things for me, so I tried looking up Custom Event which in turn came up with page [Link: https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/Events/Custom/index.html] but as before it didn’t really help me out with trying to figure out how to get blasted thing working properly .

Alright, crash course in BP / C++ logic

Event: something that occurs at some point when called
Function: something that occurs at some point when called
Notify = Event
Casting = changing or differentiating what is in use.

in anim BP you have at the start (looks different but what you need is the Cast to


Normally you already have that Is Valid node with the TryGetPawnOwner node and the Cast set up. all i’m doing here is creating a variable - drag off from As character pin (which is differently named for you because of the different cast/class/bp name) and promote to variable (not local)
Rename it to Character.
From then on you can just drag the variable in place when you need it. - is on the animation side.

Then you have the notify - An event that’s crated and called automatically by the animation. For that, let’s look at example:

The notify is called, and it does “something”. Because I need that something to be done on the character end, I take the character variable created before, and I can drag off it and find the functions and variable available inside the character BP.
Ergo, dragging of the variable you created above you can find the Received Notify function you created.
Hook that up to the notify.
You don’t really need any pins on the function either, you are just passing from the Event notify to the Character function which takes care of the rest.

Example of a function:

In case, At night you do something - is level BP stuff but your case is very similar. and let’s look at an attach to socket.
I have set up as an input event, but if you remember above the function and the event are similar. so you can do similar things with them.

Attaching to sockets:

So, that whole mess is basically taking the mesh from the current socket, Belt Right, attaching it to the Hand, and returning it to the socket belt socket (Before the animation finished playing. is backwards, but works for game-play in tandem with a camera swap, and the fact that if you delay attaching on release you end up with the compass jumping from your hand to the belt in case you double click the compass button. )

For last part.
Mesh is the character’s mesh that has sockets and bones - remember is the character blueprint.
BP_Compass is the compass added as a component - to do that in my case I’m using a child actor and setting it to be the compass. then renming the child actor. But you don’t have to do that for your static mesh weapon, it can be just a static mesh (set to movable) as you probably already have.

Last notes and differentiation functions VS Events
Events can have timers/delays, functions cannot.

To create a custom event, right click int he character BP type custom
Add custom event will show up.

from the notify character variable you can call the custom event, it will look like a function. it’s all you really need (because you do need timers).

After you figure out all the base, all you have to do is attach the component as shown, change the weapon to visible, throw a delay that matches the approximate time of when the animation finishes, make the weapon invisible, detach it or return it to where it’s supposed to be (hint, attach to pelvis bone might work).

Hope that helps, best of luck.

Alright, so far I’ve managed:

  • Adding the weapon as a static mesh to my character’s Blueprint & set it to be invisible in-game.
  • Promoting the Cast to Character event within my character’s Animation blueprint into a variable:

So now I need to figure out how to apply the Attach Component event & changing the weapon mesh’s visibility to my current existing melee attack Blueprint in order to make it work?

  1. create a custom event in character bp
  2. put the character variable near the animation notify in anim bp, drag off from the character variable and find the custom event.
  3. make the weapon appear in the custom event.
    should be all you need.

So I created the Custom Event in the character blueprint and hooked it up to the Toggle Visibility component, that way I could quickly test whether or not it worked by seeing if the weapon would appear or not.
custom_event.png

I then hooked up the new Custom Event to the Character variable I created within the Animation Blueprint:
character_set.png
However, I wasn’t sure what you meant by put the Character variable near the Animation Notify, especially since as far as I can tell the Animation Notify doesn’t appear to exist anywhere within my character’s animation blueprint. Am I supposed to cast to the Animation Notify? As when I type in the name of the Animation Notify into the search bar, the only thing that comes up within the animation blueprint Event Graph is the Cast to Animation Notify option.

Unfortunately, the current setup isn’t working as intended, despite while the weapon isn’t properly attached it should still appear visible sticking out of my character’s mesh when the attack button is pressed.

Right click anywhere and type the name of the notify.
click it.
Your variable is not set. You need to connect the pins

Copy from my first image in the explanation post and hook it up in the sequence.

Then in the notify you can use that variable. Drag from the panel (normally on left hand side) to the screen and select Get. From that you can drag off the function as you did before.

I think you need to watch some more tutorials. The animation series is a good one to understand what’s what as it explains more or less well.
might be even better:
https://www.youtube.com/playlist?lis…aR5dLHOFw4-MMl

is the other one.
Touches on sockets notifies curves. Etc.
https://www.youtube.com/playlist?lis…w42fZ1t8dDClsI

one has more explanations on montages attacks etc.

FINALLY, after being stuck on area for months I’ve finally managed get the weapon swing working properly.


https://forums.unrealengine.com/core/image/gif;base64

Although I’m not sure if I have detaching the weapon set up in the most optimal manner:


https://forums.unrealengine.com/core/image/gif;base64

I couldn’t find any tutorials on how to properly detach a component from a object so I just had to take a wild guess on to how to make it work.
​​​
However, while the weapon swinging itself is working, there’s a couple of related issues that need to be dealt with.

The most pressing issue facing me right now is with a couple of platform blueprints that I’m currently working with. You see, I’ve been experimenting with two different blueprints for platforms that the player character can jump through the underside and I haven’t been decide which to use as they both have different issues, although a problem for a different topic. Instead, the problem that needs to be addressed is that the weapon that I have attached to my character is interfering with the functionality of both types of platforms, causing issues like my character falling through the first type of platform shown below seemingly at random and camera issues with both types when jumping through the platform.

I know the source of these issues is the weapon and not something else because these problems were not present in the copy of my project I made before I tried implementing the weapon. So now I need help on how I can remove any sort of collision between the weapon and the platform while maintaining the ability for the weapon to be able to interact with other non-platform objects.

Settings for the weapon’s collision box:
151e3a95db7eedbb55ab924e5cc6f769d71942ca.png
https://forums.unrealengine.com/core/image/gif;base64

Platform Blueprint #1:
acf3679286a510f72358dbf3851cb18d6fbc22de.png ​​

Platform Blueprint #2:
3b511a2e826f791ca04827222d09bc2dc7708912.png

The other issue I’m having is a purely aesthetic one, at least as far as I can tell, and relates to the manner that the weapon is supposed to disappear after my character finishes swinging it. The weapon is supposed to disappear at the end of the animation at frame #15, with my character putting the weapon away behind their back then, but instead the weapon disappears before it reaches that point.

Earlier here in topic, it was mentioned that there is apparently a delay on when the notify activates. would then suggest that the notify is looping around to the start of the swinging animation and activating somewhere around the frame #1 instead of frame #15 as intended, if that makes any sense at all.

I’ve tried moving the notify a frame or two backwards on the track to see if that would fix the problem, but it only results in the weapon disappearing even earlier than intended with the weapon now vanishing immediately after completing the swing. Visually, it looks better than the weapon disappearing midway through the putting away portion of the animation but I’d much rather get working to how I originally intended it.

Not helping matters is that I can’t really see my character doing the pulling out or putting away animations while in-game. When the animation is viewed within the editor or in Blender, I can clearly my character carrying out the aforementioned actions, but for reason when viewed in-game its extremely hard to see as the overall animation seems faster. As a result, I’m not sure if problem is a technical one or if the weapon is disappearing behind my character’s back as intended, just at a ridiculously fast rate that I can’t see.

Any ideas?

You should be able to just enable/disable collision on the object via nodes.
Try to drag off from the bat variable and type collision, see what you get.

Re the notify. Is the animation 1 animation or 2/3 animations combined?
From what you are saying it seems like you are triggering the “put away” at the end of the swing, but there is more animation playing until the weapon is put away so you just need to move the notify further down the animation- or to the other animation in case you are using multiple animations for .

Re the animation speed, check that the speed rate is 1 and hasn’t been changed within the animation.
The framerates doesnt really seem to matter in unreal. Generally 30fps gives you a 1:1 frame.count between FBX and Ue4. 60fps does not. At least in blender.

Is there anyway of just removing any interaction between the weapon and the platform altogether? I can’t think of any reason why I would need the weapon to be able to interact with the platform and so I think it would be better just to remove it. Also, my problem with enabling/disabling collision is that, in theory, if the character swings their weapon at an enemy while jumping through the platform, the weapon will end up passing harmlessly through the enemy instead of dealing damage. I know you can create custom collisions as I’ve seen it in at least one tutorial video I watched on YouTube, although I’m not sure if that would be the proper way of going about removing the weapon/platform interaction or if it can be done with the preexisting collision settings.

Its one whole animation consisting of 15 frames with the Animation Notify for putting away the weapon on the very last frame. If by “move the notify further down the animation” you mean move the Animation Notify forward a couple of frames instead of backwards, then that’s going to be a bit of an issue since as I just said, the Notify is on the final frame of the animation & therefore can’t be moved further forward.

For the collision you can select what interacts with what in the collision options for the item/mesh/object

For the a I’m notify, you may consider adding a few frames. 15 frames for a weapon swing where you also extract and put away the weapon seems really low. An avarage extract animation at 30fps is about 15frames…

Alright, so it turned out that the tutorial Link] I followed to make the first platform blueprint also included how to setup custom collisions for objects interacting with the platform, and now I no longer have any issues with the character’s weapon interfering with the platform.

As for the Animation Notify issue, I noticed that the ground-based version of the swing animation was missing a couple of frames at the end, which was rather odd since the jumping/falling variants consisted of 17 frames compared to the ground-based versions’ 15 frames. So I re-imported the animation from Blender which added the missing frames back in and then tried re-positioning the Notify in a variety of different areas along the timeline, but no matter what, the weapon would always disappear too early. Not helping matters is that for some reason if I try to place the Notify on the final frame (#17) it won’t play the Notify at all. I don’t remember being the case before I re-imported the animation so I’m not sure what’s going on.

Since you also mentioned attaching the Notify to another animation, I decided to try & attach the Notify instead to my character’s idle animation since the swinging animation transitions back into the idle animation. however did not go well as it instead it caused the weapon swinging to glitch out.

I’m not really sure what to do now, especially since I don’t really want to re-animate the whole animation again as not only it is a hassle to do but the current speed at which my character swings their weapon is pretty much ideal I feel & so I don’t really want to extend it a whole lot. Function trumps form for me, as I want my character’s close-range attack to be fast & responsive to go along with the quick platforming nature of the game I’m building which is more in the vein of something like Mario, Sonic, Crash or Klonoa, and not something like Dark Souls which favours slower, drawn-out attack animations befitting its own more methodical-style of gameplay.

For the time being though, the most important thing is that attack swing appears to be perfectly functional in its current state, so I should be able to progress onward with the development of my game even if the animation itself isn’t perfect.

place the notify at frame 16, add a delay of around .25 (eyeball how many seconds you need) before the command to hide the weapon… it’s a hack, but it costs you nothing to do.

I’ve finally managed to fix the problem by deciding to bite the bullet and re-animating the swing animation. The new animation is almost twice as long as the old one, although I had to go back a second time and shorten the animation by four frames to get it to properly work with the Animation Notify. I guess the animation can’t be too short or too long in order for the Notify to function correctly.

Anyways, everything now seems to be in more-or-less working order, so thanks for all the help!

I figured out.

I have an anim montage in which I need to spawn a KNIFE into the players hand and then destroy(hide) it when the montage is done. The player takes out and places knife back in the montage, just like unhiding the weapon during a strike.

Overview.
Make a visibility variable (boolean)
Make your animation into a montage.
Create an Anim Notify Blueprint Class for unhiding and hiding the weapon
place the weapon static mesh INTO your character’s BLUEPRINT as a child actor of the Mesh component. way your BP can always have access to the weapon he always uses for that attack everytime.
Place the anim notify blueprints into your montage in the notify track.