Spawning a object during animation

As stated in the title of topic, I was wondering how does one go about spawning a object when a animation is playing?

You see I’m trying to make a attack animation for my player character where the character reaches behind their back and pulls out a weapon à la Looney Toons. The character then swings their weapon and then puts the weapon back behind their back where the weapon then disappears.

I’ve created the necessary animation and have mapped to the animation blueprint, so everything is in place except for the missing weapon.

I was also wondering about rotating a object during animation as well. The reason for is because as part of the act of swinging the weapon in a downward motion, it is necessary for the swinger to turn their wrists downwards, which is a problem because my character doesn’t have any hands. Instead my character has sausage-like limbs, necessitating the weapon to rotate its position in order to simulate a person turning their wrists downwards. Without the simulation of turning one’s wrists during a swing, my character would have a non-existent attack range due to his rather short arms, causing a variety of gameplay issues.

Any help whatsoever would be greatly appreciated!

You want to call SpawnActor to get your weapon into the game. Then you attach the weapon to your mesh via a socket. When you are done simply detach and call Destory on the weapon actor.

You can also add a curve (either standalone or to the animation itself) to represent the amount of rotation your weapon should have. Then during animation play you can update the weapon transform based on the the curve values.

Ok now I feel like I’m spamming but last response for sure time. It occurs to me you don’t need a mesh for an armature to work correctly. The easiest way to do would be to simply author your animations with a hand/weapon bone. You don’t need to have a hand mesh to go along with it. way you’d get the most accurate animation control for your character.

I was going to suggest just that.
depending on the weapon of course. If it’s just a mallet and has no player controls a one shot animation works best.

if you need to pull out a gun and need to trigger it things get more complicated.
if you want the mallet to “find” the enemy things get more complicated too…

If you wanted to go the crazy way about it you could create a morph target weapon, flatten out its geometry so it’s essentially invisible and inflate it during animation time with a morph target…
You did say LOONEY Toons…

Thanks for suggestion, adding a “grip” bone has greatly simplified things. If I had tried to animate the movement of my character’s weapon otherwise, it almost certainly would have turned into a overly complicated nightmare. I also had to modified the swinging animation a bit due to the fact that I originally made the animation without the required weapon in hand and so attaching it to the newly created “grip” bone exposed that the weapon would end up clipping through my character.

Unfortunately though, fixing that one problem has created a new one in its place that is now currently vexing me. After creating a socket on the new “grip” bone I tried to include a Add Preview Asset so that I would be able to see the weapon on my character while trying to figure out the blueprint for the Animation Notifies to spawn/despawn the weapon in the animation. However, instead of the weapon appearing in my character’s “hand”, the weapon instead appeared in the middle of the character model. I then tried to move the weapon asset over to the where the “grip” bone was, but for some reason I could not move the weapon, I could alter its scaling & rotate it but I could not move the object from its default position.

While trying to figure out why I couldn’t move the weapon object to its proper location, I noticed that in the bone hierarchy displayed on the left side on the screen that “grip” bone appeared grayed out along with a bunch of bones that were based modifiers from Blender that were incompatible with Unreal Engine 4. Highlighting the grayed out bones would display the following message:

I tried doing a Google Search for message and came across topic:

https://forums.unrealengine.com/deve…e-current-mesh

I’m fairly certain the problem scenario described in the above topic is the same one that I am currently with, but I have no idea how to fix issue. I tried re-importing my character model from Blender without any of the bones that used modifiers from Blender that were incompatible with Unreal Engine 4. I also made some changes to all of the animations I’ve made to date by highlighting all of the bones within the armature minus the aforementioned incompatible “modifier” bones and choosing to export only the bones I had highlighted.

Alas though, despite all of the my efforts of re-importing the mesh/armature and all of its animations, the problem continues to persist just as it did before I made all of my alterations.

Does anyone have any idea on how I can rectify new problem?

**EDIT: **I thought I should also mention that despite deleting the “modifier” bones from my model and not including them in the animation armatures when I exported them as a .FBX file, the bones are still present in my model’s armature in Unreal Engine 4. I’m not sure whether or not is directly related to why the “grip” bones aren’t being properly registered by Unreal but I thought I should mention just in case.

I don’t know what you are doing exactly but I can tell you :
In blender when you delete things from an armor and it still imports the same things in the armor the more likely reason is that you may have removed the items on the Pose and not in Edit Mode.
Editmode deletions propagate to pose mode. Vieceversa they do not.
Your animation is likely Baked (that’s usually how blender imports from an FBX, 1 key every frame). Before exporting you need to NLA Bake the action with visual and whatever other options within the panel you think appropriate - Then the files can be re-imported and the armature changes will take place without issue.

For putting the weapon in hand and animating - depending on actual needs (since your need is to spawn via BP you’ll have to work the BP ) - you can try following the sequencer tutorial.

It’s not in Blender where the deleted bones are reappearing but Unreal Engine. The only reason I can think of why happening is because the main character model & all of its animations are being imported into Unreal Engine from two different Blend files. The Blend file with the main model is the one that I deleted the “modifier” bones from, while the other one containing all of my character’s animation maintained those bones because I needed the Inverse Kinematics bone restraint to animate my character. Instead, I tried selecting all necessary bones while leaving out the “modifier” bones that were not compatible with Unreal Engine & turned on Selected Objects in the Export FBX options. I guess its possible that the Selected Objects option didn’t work as I intended and instead imported the entire armature rather than just the bones I selected.

However, while I would prefer to get rid of the incompatible bones that serve no purpose in Unreal Engine, none of explains why the “grip” bones I added to my model for the purpose of attaching the weapon to isn’t working properly, making it my primary concern.

I have no idea why the “grip” bones aren’t working, the only thing I’ve noticed is that the two bones aren’t listed in the Dope Sheet Summary for the vast majority of the animations I’ve created so far, but I’m not sure whether that is something to be concerned about or not.

Er… no… the function worked exactly as intended - but a bone is not an object… the armature is.

So… here is an abstract of the normal blender to ue4 workflow.

  1. Import in an FBX (with or without animation)
  2. Rig / or otherwise do the required setup and scaling
  3. Animate / Work
  4. Export to FBX
  5. Import into UE4
  6. Apply real materials instead of the crap from blender.
  7. Put it where it needs to go (anim bp? map/level? etc.)

So - going with that… Just export from UE4 the animation in question as an asset with a preview mesh. (you can actually watch me do it on some of my vids…
https://youtu.be/NYbJBocZUTM?t=303)
Import to blender
Work on it (remove the bones in edit mode!)
and then import it into UE4 again selecting None as the skeleton to generate a new one.

Also, note that you can NLA Bake only the Selected Bones - and that if you click the animation export options you have an option to export only the deform bones.
So, ideally you can select the bones in Pose Mode that you need to have in UE4, Bake the animation, Turn on the Only Deform during export, and have only those bones within the armature in the new skeleton you generate in unreal.

Then ofc you need to retarget all the old animations to work with new skeleton.

Let me know if that helps.

I finally figured out why the bones that the weapon is suppose to attach to isn’t working. Its turn out that I forgot to add the bones to the main mesh/armature model Blend file, only adding them to the animation Blend file. Once I added the bones and re-exported the model as a FBX file into Unreal Engine, the bones were properly working. The Inverse Kinematic controller bones that are incompatible with Unreal Engine are still there but they’re not really a priority right now or perhaps ever.

However, what is a problem though is that after adding the socket to the grip bone and choosing to add a preview of the weapon model results in the preview being ridiculously larger than it’s intended size. As to why is happening, I have no idea as I checked the original Blend file of the weapon to see if the scaling units were wrong or if the scaling hadn’t been applied, since that has caused me some problems in the past, but there didn’t seem to be any scaling issues that I could see. Moreover if I drag the weapon out directly into the level in Unreal Engine, the weapon appears at its proper size, so I not sure if the problem lies with the weapon model itself or if issue is restricted to the preview only.

I also tried shrinking the preview weapon but I could only shrink the weapon so far before it would disappear entirely, so that’s not really a solution either.

I only thing I’ve noticed out of ordinary that might be connected, is that after adding the socket to the “grip” bone, a large diamond-shaped outline larger than my character model appears, extending outwards from the location of the socket. I don’t know what diamond-shaped outline is, as it doesn’t appear in the video tutorial I’ve been using [Link: Sword Weapon Blueprint - #20 Creating A Role Playing Game With Unreal Engine 4 - YouTube]. Whether the diamond outline was perhaps something that was added to Unreal Engine in the subsequent two years after the video was originally posted or something else entirely, I don’t know.

Argh, it’s been way to long since I last addressed issue, anyway though, since the last time I posted here I found some additional information about why my weapon model is ending up so gigantic when I place it in the “grip” socket of my character model.

After searching online for a bit, I came other posts of people experiencing the same problem as me like in link. Evidently, the giant diamond-shaped outline I mentioned before that appeared around my character is actually the “grip” socket itself, and for whatever reason the socket is being scaled upwards to a massive degree. The result is that any object I that attach to the socket will be scaled to the same size, hence why the weapon ends up gigantic when attached to the socket but appears in it’s proper size when I drag it out into the main scene.

After reading all of these similar plights as mine though, I haven’t been able to identify any singular fix to problem. Does anyone here know to how deal with giant socket issue?

I can manually scale the socket down to size but I’m not sure if that is the most optimal approach to fixing problem.

socket_transform.png
Are you not seeing the transform controls?
check that relative scale is 1 all across.

I can see the Transform Controls and the Relative Scale is 1.0 across all axes but for some reason attaching a object to the socket results in the attached object being expanded in size to a ridiculous degree.

Whatever the problem is, its not with the Weapon Object I created as I tried to attaching a default cube from Unreal Engine 4 onto the socket and the cube was also greatly expanded in size.

While I was reading other people’s experiences that were similar to my current predicament, I saw a couple of posts that said the problem with the socket is the result of a glitch involving adding sockets to a model imported from Blender. I have no idea whether or not is actually the case as I can’t seem to find any other causes for issue.

I can manually adjust the scale of the socket myself but my concern with is that I don’t know what scale the socket is being sized to. You see if I scale the socket down to 0.01 or 1% of its original size than the attached object ends up too small, whereas if I adjust the scale to 0.02 then the attached object appears to be at its intended size. The keyword though is “appears” as I can’t say for certain if the attached object and by extension the socket is actually at its proper size or not, even with my character model with the equipped weapon opened in Blender as a visual reference. For all I know, the Weapon Object/socket could be a bit too big or too small, and while isn’t a big deal for particular object, it is for things like clothing that need to maintain a 1:1 scale with my character model in order to prevent things like clipping from occurring.

Since I had to reduce the socket’s scale to 0.02 or 2% of its original size in order to get the attached weapon to appear at its relative proper size, I would have to conclude that the socket isn’t being scaled by a factor of 100, but I also don’t know if its necessarily being scaled by a factor of 50 either, it could be 49 or 48.554 for all I know. why I would much rather figure out how to fix problem so that attached objects will appear at the intended scale without having to waste time fiddling around with the Relative Scale to try and match the original object’s size.

What happens if you delete the socket and add it back?
Even better, add another socket to the same bone and see if the scale is huge or not…

If it is, you should consider saving out a copy of the project, removing everything except the character mesh/skeleton/weapon and submitting a bug report with it.

I tried doing both of these things but it didn’t make a difference. Out of curiosity, I tried adding a socket to the head bone and just like the grip bone, the resulting socket was over-sized. So whatever the problem is, it would appear to affect the entire armature rather than just one bone, which I figured would be the case.

I guess I should get around to doing since I’m guessing that there’s nothing else that can be done at point.

I suppose I’ll have to keep going forward on my work continuing with the socket scaled down to 2% of it’s original size and hope that it doesn’t cause any issues down the road.

Getting back to the subject of spawning a object during animation, I need help with trying to figure out how to setup the blueprint for the Animation Notify intended to call the Weapon Object into the swinging animation.

I haven’t been able to find any tutorials online how to accomplish , the closest being one:

Link: https://docs.unrealengine.com/en-US/Gameplay/HowTo/SpawnAndDestroyActors/Blueprints/index.html

But I’m not sure whether or not guide is applicable to what I’m trying to do, so I instead tried using a more general tutorial on attaching a object to a character via blueprint with the hope of being able to apply it to the Animation Notify blueprint. No such luck though, as my efforts have not gone well at well:

Can’t say I’m surprised it didn’t work. Shouldn’t the target for the Get Socket Transform be the character mesh not the weapon? I couldn’t find any way of setting the target as the character model, assuming that is what I’m supposed to do. I wouldn’t know seeing as I have absolutely no idea whatsoever as to what I’m doing, which is why I need with .

Before you do though file a report though.
is uaing Epic’s mannequin or have you modified it in any way?
its sounding a bit like your skeleton is scaled down or up in the FBX.

As far as attaching the weapon you need to activate some backward problem solving thinking.

Anim notify is avaliable in AnimBP (as an event)
To transfer to character BP you need to trigger a bool on the character (with a cast to characterbp ).

Even better, skip the bool entierly and just call a custom event you create (which you have already done basically even if it’s wrong currently).
Custom event btw, not a function like above, because dealing with animations you may want to use timelines and delays etc.

As far as the attach to socket goes.

  1. put the weapon inside the character BP. (Maybe hide it inside or mark owner no see or mark hidden in game).
  2. create the attaching mechanic and trigger visible if you had made it invisible.
  3. profit.

Here is an example of attaching with custom offsets because it’s what I have open…


Note:
Mesh is the character, BP Compass is the component i’m attaching to the socket (a skeletal mesh in my case, but it can be a static one).

Nope, the skeleton is entirely custom-made since my character doesn’t even remotely look human. There doesn’t seem to any other scaling problems with my character model, so I’m not sure why it seems to be only affecting the sockets I add to it.

As for attaching the weapon to my character, I’ve managed to get the weapon itself attached but there is a couple of issues that need to be dealt with.

Firstly, I can’t seem to figure out how to make the weapon appear & disappear through Animation Notify. Specifically, I’ve been unable to set the target for toggling the visibility on/off as the attached weapon.

Setup for the attached weapon in my character’s Blueprint:

The second problem I’m having is with the attached weapon’s collision box for interacting with targets. The problem with the setup I currently have is that the weapon attached to my character’s hand will do damage to a target simply by touching them even though the character isn’t attacking. Basically, I need some way of ensuring that the weapon’s collision box will only take effect while my character is carrying out their attack animation and not through just any sort of contact.

With what you are describing the process you are using is incorrect.

maybe you need to exaclty show us what you intend to have happen

Right now it just seems like you are unholstering a weapon and using it.

What I thought you wanted was to have 1 specific attack animation spawn the weapon perform the attack and make the weapon disappear.

is what I’m trying to do, as outlined here:

  • **Frame #1-3: **Character reaches behind their back and the weapon appears in their hand.
  • **Frame #4-5: **Character lifts the weapon above their hand and then swings downwards. Its during phase of the animation that the box collision for dealing damage should take place.
  • **Frame #6-7: **Character puts the weapon behind their back & the weapon disappears.

I thought you meant that I should instead try having the weapon always attached to the character and instead switch between the weapon being visible/invisible.

My biggest problem I’ve encountered so far is that I have no idea how to properly set things up within the Animation Notify being called upon in the animation itself. Not helping matters is that I can’t seem to find any specific tutorials online on how to use Animation Notifies for I’ trying to accomplish, and thus I am now completely lost.

A notify is nothing but an event.
The only difference is that it’s an event for the Animation blueprint.

So after you create the notify you can call it in by typing the same name in the animation blueprint.

You can then cast to character as any tutorial and even the base BPs show you, and call another custom event from the character pin in order to take things on the character BP and handle from there.

on here is where you will attach to socket (not spawn) and resize the weapon as needed via nodes/code.
once attached you’ll already be into frame 2 or 3 of the animation as the notify is deferred and not instant nor does it cause the animation to delay

  • which is exactly what you want since you have a 1 swing sequence the attachment is not all that important as it will generally happen when the notify calls it or a few ms later.

The swinging will continue as normal and the hitbox/collision should no longer matter since it can always be active.

Have you seen any other tutorials about attaching to socket?
you need the weapon to be somewhere inside the character (not attached, inside the actual mesh of the character). And set to hidden in game.

Then at the same time you attach you can also make it visible. Maybe with a timeline based lerp for an even more cartoon like feel. Materializes/disappears sort of thing.

should be all fairly straightforward once you get a handle on how animbp and blueprint work in tandem / get familiar with the socket system.