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

                  Working...
                  X