Announcement

Collapse
No announcement yet.

Spawning a object during animation

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Before you do though file a report though.
    is this 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...
    Click image for larger version  Name:	attachtosoket.png Views:	1 Size:	101.9 KB ID:	1659869
    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).
    Last edited by MostHost LA; 09-02-2019, 02:37 PM.

    Comment


      #17

      Before you do though file a report though.
      is this 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.
      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:
      Click image for larger version

Name:	weapon_attach.png
Views:	1
Size:	113.3 KB
ID:	1663837

      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.

      Comment


        #18
        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.

        Comment


          #19
          What I thought you wanted was to have 1 specific attack animation spawn the weapon perform the attack and make the weapon disappear.
          This is what I'm trying to do, as outlined here:
          Click image for larger version

Name:	ref.png
Views:	1
Size:	14.8 KB
ID:	1664577
          • 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 this 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.
          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.
          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.

          Comment


            #20
            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.

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

            Comment


              #21
              Okay, I have absolutely no idea as to what I'm doing .

              Click image for larger version

Name:	lost.png
Views:	2
Size:	120.3 KB
ID:	1665063
              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 this 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 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.
              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 this description:

              Events are nodes that are called from gameplay code to begin execution of an individual network within the EventGraph. They allow Blueprints to perform a series of actions in response to certain events that occur within the game, such as the game beginning, the level being reset, taking damage, etc. These events can be accessed within Blueprints in order to implement new functionality or override or augment the default functionality. Any number of Events can be used within a single EventGraph; though only one of each type may be used.
              Unfortunately, this didn't help clarify things for me, so I tried looking up Custom Event which in turn came up with this page [Link: https://docs.unrealengine.com/en-US/...tom/index.html] but as before it didn't really help me out with trying to figure out how to get this blasted thing working properly .
              Attached Files

              Comment


                #22
                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 this at the start (looks different but what you need is the Cast to
                Click image for larger version

Name:	AnimBPMovement.png
Views:	2
Size:	186.2 KB
ID:	1665435
                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. - This 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 this example:
                Click image for larger version

Name:	charactervariablespeed.png
Views:	2
Size:	380.3 KB
ID:	1665436

                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:
                Click image for larger version

Name:	FunctionNightTime.png
Views:	1
Size:	302.7 KB
ID:	1665437

                In this case, At night you do something - this is level BP stuff but your case is very similar. and let's look at an attach to socket.
                I have this 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:
                Click image for larger version

Name:	AttachToSocket.png
Views:	1
Size:	392.8 KB
ID:	1665438

                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. this 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 this last part.
                Mesh is the character's mesh that has sockets and bones - remember this 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.

                Comment


                  #23
                  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:
                  Click image for larger version

Name:	setup.png
Views:	1
Size:	155.5 KB
ID:	1667482

                  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?

                  Click image for larger version

Name:	attack_bp.png
Views:	1
Size:	199.1 KB
ID:	1667483

                  Comment


                    #24
                    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.

                    Comment


                      #25
                      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.
                      Click image for larger version

Name:	custom_event.png
Views:	1
Size:	38.7 KB
ID:	1667747

                      I then hooked up the new Custom Event to the Character variable I created within the Animation Blueprint:
                      Click image for larger version

Name:	character_set.png
Views:	1
Size:	33.2 KB
ID:	1667748
                      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.

                      Comment


                        #26
                        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.
                        this might be even better:
                        https://www.youtube.com/playlist?lis...aR5dLHOFw4-MMl

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

                        This one has more explanations on montages attacks etc.
                        https://www.youtube.com/playlist?lis...iN877q9u_v_oZB
                        Last edited by MostHost LA; 09-23-2019, 07:04 PM.

                        Comment


                          #27
                          FINALLY, after being stuck on this area for months I've finally managed get the weapon swing working properly.
                          Click image for larger version

Name:	anim_bp.png
Views:	1
Size:	159.8 KB
ID:	1672552

                          Although I'm not sure if I have detaching the weapon set up in the most optimal manner:
                          Click image for larger version

Name:	chara_bp.png
Views:	1
Size:	153.3 KB
ID:	1672553

                          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 this 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:
                          Click image for larger version

Name:	collision_settings.png
Views:	1
Size:	36.3 KB
ID:	1672554

                          Platform Blueprint #1:
                          Click image for larger version  Name:	platform_bp_1.png Views:	1 Size:	224.1 KB ID:	1672550 ​​

                          Platform Blueprint #2:
                          Click image for larger version  Name:	platform_bp_2.png Views:	1 Size:	180.2 KB ID:	1672551

                          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 this topic, it was mentioned that there is apparently a delay on when the notify activates. This 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.
                          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.
                          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 this 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?
                          Last edited by Hungry Moogle; 10-10-2019, 01:13 AM.

                          Comment


                            #28
                            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 this.

                            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.

                            Comment


                              #29
                              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.
                              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.

                              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 this.
                              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.

                              Comment


                                #30
                                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...

                                Comment

                                Working...
                                X