Hello, to start off i want to say im fairly new to unreal engine but i have stumbled upon a problem i currently dont know how to solve and i can’t find any information online.
So i imported a cigarette smoking animation from mixamo and in the animation the character is supposed pull a cigarette out of the box but i was wondering if it was possible to spawn a cigarette and attach it to a Skeletal mesh socket in the middle of the animation.
so the character doesnt pull out a cigarette with already a cigarette in their hand.
(I want this to happen outside of a cinematic)
If anybody knows something to achieve this effect, or has any tips i would really appreciate that
thanks in advance!
Hey @Sandmanxan, welcome to the Unreal Engine Community!
The best method for achieving this is going to be use of Animation Notifies. Animation Notifies allow you to trigger game logic when a certain frame in your animation has been reached; in your example, you would need to find the frame of the animation where the character pulls the cigarette out of the pack, and stick a notify on that frame.
You’ll need to do some setup first. You’ll need to attach a socket to your actor’s hand where the cigarette should go, and then attach the cigarette mesh to that socket and orient it appropriately. Then you’ll need to setup your actual animation notifies and the event execution logic. To spawn the cigarette actor simply use a Spawn Actor node, to attach it to a specific socket you’ll use Attach Actor to Component, with the component parent being your character’s skeletal mesh and the target being the newly created actor.
I found a great non-epic-affiliated tutorial on how to go through this step by step; this video does not include spawning the actor to be attached but does go over some of the more complicated animation notify setup.
I hope this information helps, and again, welcome to the Unreal Engine Community!
2 Likes
Hello thank you very much for your response. I have followed the tutorial but my Casts are failing, which resulted in a script that does not run. I personally think this is because the character is not actually possesed by me? i dont really know.
But yeah i basically want to spawn a static mesh on a actor
(or pawn if that is my only possibility)
so if you know anything that will help me or if a have done something stupid please let me know and ill try to get back to you as soon as possible.
I have Found the way, Thank you so much for setting me a step forward in the right direction.
Ill post a screenshot of how i have done it down below for my felow developers.
(With some simple explanation.)
Edit : with the variables set i can now use the notifies in the animation to set the visibility of the object.