Is there a way to alter physics to effect only 1 or 2 planes?

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.

  1. I first come out of a begin overlap of a box collision in the barrel bp.
  2. 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.
  3. Added a sound effect of a grunt as if the character strains to pick up the barrel.
  4. Set a “Held Item” obj variable in the TPC bp.
  5. Set Max Walk Speed to 75 or lower to simulate carrying something heavy.
  6. Set an Enum in the TPC bp to “Barrel” to signify what weapon the TPC has.

  1. Set the TPC variable “Has Any Weapon?” to true.

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

  3. At the top of the Barrel bp, I have an Event Tick that feeds a sequence with two pins.

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

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

  1. And finally out of the Detach TPC custom event I play the throw barrel animation.
  2. 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.
  3. 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!

1 Like

Is there a way to alter physics to effect only 1 or 2 planes?

You can do this dynamically, too.

1 Like

Wow thanks Everynone! It really was simple lol. I was able to get exactly what I asked for!

Actually I had to just tick the box to lock Z rotation seems to do what I wanted.

@ Everynone, how can I get something like Event On Landed inside an actor bp?

You could use OnHit, then DoOnce to prevent spam. You could filter the hit with a tag.


Providing the floor has a tag:

  • in the actor that is “landing”:

See if this delivers.

1 Like

I can’t get it to work yet. I have generate hit events ticked on both the floor mesh and the barrel static mesh. Any ideas?

Ahh its a tag problem, took the branch out and it worked to print string. Ok yeah just a spelling error. Everynone you never disappoint! Well done.

1 Like

If it keeps spamming Hits, you can try resetting the DoOnce only once the item is picked up again. Also, it does not need to be an actor, every component can generate onHit:

image

Can be handy if your actor has many comps.

1 Like

You have taught me alot, yes this will definitely be handy in the future. Right now I can’t quite dial it in physics to get the whole effect I wanted, like roll enough, while still high enough etc etc. Which is why I wanted an event on landed, perhaps to give it more of a horizontal push once it hits the ground to make it roll longer. Or perhaps try to create my own bounces with diminishing returns until no more visible bounce.

Or…I may have to try and make something without physics. Maybe I just don’t have everything dialed in right on the physics settings. Thanks again man for all the help!

Aye, physics does need tweaking, indeed! Not sure how you do the barrel tossing, atm but

  • if this was in the player:

[it’s the default cylinder that is oriented not as we need - hence the :point_up_2: Up vector]

  • and this in the barrel:

[the directions are weirdly hard-coded here due to time-constraints]

  • we could get a somewhat convincing:


When it comes to tweaking - here’s a kickstarter on physical materials:

  • create a new one:

  • double click it to open, and have a look at the tooltips to find out what the options do:

For example:

  • image

  • image


You could apply it to surfaces and / or objects.

  • think slippery ice covered level. :ice_cube:
  • or the player gets a new ability that lets them toss bouncy barrels by applying a restitution intense physical material

Another idea for something like this is to treat the scene props as projectiles. You fire them as if they were bullets, and have the projectile movement component do the heavy lifting. This could get handy if you want to easily make an auto-targetting homing knife, for example:

Because why not.

1 Like

Ok so I assume in my case you want me to destroy the attached barrel while simultaneously creating a new one and applying force to it.

Before I destroy it check this out..

That is actually decent.

At first I didn’t get the destroy to work with the spawn actor but I looked again and seen where you said some of the code was in the character and some in barrel BP. When I did that it worked. But for anyone out there wondering, here are some things I had to do to get this method to work.

To try to get the exact location of the barrel as the character holds it over his head just before the button is pressed, I made a transform variable and called it “Barrel Transform”.
I added a sequence after the montage and before the detach. The first pin goes out to the detach, the second goes to a do once to turn the flow into a single pulse and set that variable.

I also created an Event Dispatcher (and this is in the barrel bp) and dragged and dropped it and called it.

Then back in the TPC bp, I added the code you suggested, and from my Barrel Actor Ref (which I converted to a validated get to hopefully avoid errors) I got my transform variable and chose to bind the spawn barrel dispatcher.

And this is about all I know about event dispatchers, the call and the bind. And here is the results below.

I briefly messed with that some last night, you can really change the bounce with that restitution control.

The ole auto homing and glowing knife lol. Makes me think of this..

I once had it where the enemy NPC would go to and pick up the knife, and if lined up for 2 seconds would throw it. I wasn’t using the projectile movement component, but as you say that could potentially save a lot of time. I’m trying to do a duality with the weapons in this Beat EM Up template. For example. the bat can be swung (kick button), but it can also be thrown (punch button), There are advantages for each, for example the knife could be used as a melee weapon for much more than one attack, but if thrown and it hits them it is an instakill for most NPCs. However throwing a weapon you only get one ■■■■. Also I want the beer bottle to give health, then the player can throw it.

Thanks for taking the time to make that detailed reply. I had never done this before as in destroying an actor then remaking it, I’m surprised it actually looks as seamless as it does. Of course more tweeking will have to be done to it. I figure I can also make a big rock weapon that can use about the same mechanisms of action as the barrel, which could be useful for a big Gorn.

Once I began messing with settings, I discovered that that code in the TPC was not firing at all lol. So, there was something else applying force to that barrel…it was this part of the code at the top of the barrel bp.

Which reminds me of the thing you said to me awhile back about how that sometimes things happen in Unreal and we don’t know why but we are just glad they did or something like that lol. And this is one of those times.

Now I have to find out why the reference for the barrel is showing not valid.

Nah, that was just a quicky physics example to demo. Since you’re already holding an actor, no need to destroy and spawn a new one.

I did not have enough time to replicate the entire setup you have.

1 Like

Ahh ok, well I was hoping I would get to use the same one. It just seems better that way.

Here I am trying to get the destroy then remake the actor and sling it. Well I have got it back to using gravity to drop when it is detached / key pressed.

As you will see in this video the gravity and physics are working, but that impulse node is adding no force at all. Any ideas?

A few things. I seen the get forward vector was wrong so I dragged out from the static mesh (barrel actor) to get the component and plugged it in. Nothing, tried just using settings in the node, nothing. Tried the “add force” node and tried using settings in it, still nothing.

Not enought force. Tick vel change. Up it to 2k. Without vel change you’d need like 200k or more depending on how much it weights.

1 Like

That did the trick! Thx. Here is the effect of these settings.

I added some more stuff to make it more like the final version. I took one of the knock down animations, and I cut it so it was just the one frame of the enemy NPC down on the ground. If they touch a rolling barrel they are instantly on the ground. I found there was some root motion on this that cause them to slide on the floor, I was able to stop that with these settings.

However, I can’t seem to fix the rotation issue, I have tryed rotating, adding a key, and saving and nothing. This kind of thing is what I use the “Null Instant Turn” variable for in the enemy bp. But I tried both on and off and nothing. Do you have any ideas how to rotate that animation and save it? Thanks again man.