In this Beat Em Up example video, you will see the TPC pick up a barrel off the ground and throw it. You will see that after a few feet of rolling it kind of skids out and goes sideways. So the question then is can I turn off the X in physics and leave the Y and Z so I have the drop / throw, and bounce and then the roll?
First let me run through the process and lay out the important stuff. The weapon (Barrel) has its own actor BP.
- I first come out of a begin overlap of a box collision in the barrel bp.
- Which then comes to a boolean that checks Has Any Weapon?
3.Then I check if the gamepad facebutton is being pressed AND the TPC’s capsule is also overlapping a bigger or rather taller box collision called “pickup box”. This is the main attach mechanic. - Added a sound effect of a grunt as if the character strains to pick up the barrel.
- Set a “Held Item” obj variable in the TPC bp.
- Set Max Walk Speed to 75 or lower to simulate carrying something heavy.
- Set an Enum in the TPC bp to “Barrel” to signify what weapon the TPC has.
-
Set the TPC variable “Has Any Weapon?” to true.
-
Set the Barrel actor bp variable “Detached?” to false.
3.Hit a sequence with 3 pins that first goes to a Play Anim Montage to play the pickup barrel animation, twhich is then fed to a disable input, into a delay hooked into the montage, then TPC variable “Carrying?” is set to true. Then the input is re-enabled. The second pin of the sequence goes to a set visibility of the barrel mesh to be invisible, then the third pin of the sequence goes to a delay node set to .45 then into a set visible node set to make the mesh visible again, I found this looked to me a little cleaner rather then have the barrel instantly appear in the TPC’s hand while moving down to pick it up off the ground at the moment of attach.
-
At the top of the Barrel bp, I have an Event Tick that feeds a sequence with two pins.
-
Out of the first pin I first hit a branch that checks if the face button left (which I use for punch) is pressed AND if the TPC Variable “Carrying?” is true.
3.Which then goes through a do once node, and then into a custom event “Detach TPC” which is at the bottom of the BP (will show later).
4.The second pin of that sequence goes to a branch that checks if “Detached?” is true. -
Then it hits a branch that checks if the TPC variable “Facing Right?” to set up two identical but parallel logic pathway. I discovered that with physics turned on the attach does not work with the mesh, so I first set simulate physics to on, and set enable gravity to be on (not sure if this is the correct order but I had to turn physics on first and then gravity else the gravity did not work). And finally into an Add Impulse node to drive the reaction.
- And finally out of the Detach TPC custom event I play the throw barrel animation.
- I detach the actor from the TPC.
3.Play a sound effect for the throw.
4.Set the TPC variable “Detached?” to true.
5.Set the TPC variable “Carrying?” to false. - And finally set the weapon enum to “noweapon”.
The only thing in this bp I did not show was getting a ref to the TPC, Perhaps I should have just used a validated get of that ref instead of get actor of class in line 1 of the attach.
Is there a better easier way of what I have here? Any ideas or solutions for the physics situation? Should I turn physics off once the barrel hits the ground and just manually try to rotate and move it forward?
Any help is greatly appreciated thanks!
























