How can I make my character affected by physics?

Hi,

I’m trying to make a character affected by a slippery surface in U4. I created a physics material and assigned it to material of my floor. Upon this other pawns (such as cubes) are being affected by it, but my character doesn’t move at all.

If I disable simulate physics at my character’s capsule component, character moves, but if I turn it on, character stays immovable.

Any ideas?

Cheers!

1 Like

Hey fdjveiga,

Would you mind showing us what your physics material setup is, and what your character controller looks like? I’m guessing your character movement is what’s causing problem here, but if I can see it I might be able to see how. Thanks!

Hi,

So, I am using TP_FirstPerson example, where everything is default in character except:

  • Checking box for simulate physics in capsule component.
  • Setting PhysicsActor as collision preset in capsule component.

As for physics material, I created a new physics material and set friction to -1000.

Cheers!

Just an update,

There’s no need to change physics material, it is enough to only enable physics simulation in characters capsule component that it will not move anymore.

Any ideas?

Okay, it sounds like you haven’t messed with Character Movement settings yet. In your character’s Defaults tab, scroll down to Character Movement section. In there, take a look at Ground Friction and set that to a number greater than zero but probably less than 1. Then look further down for Max Acceleration and, more importantly if you’re looking to replicate an icy surface, Braking Deceleration Walking. Drop that down to zero to start with.

That should help you get what you’re looking for, though you’ll probably want to fiddle with those numbers some.

Hope that helps!

Hi,

Thanks for tips!

Still, is it not possible to use physic materials in world to affect my Character, not relying on messing with CharacterMovement?

Cheers

Normally you would change settings on movement component rather than materials in world. I think it was done this way so that you could tweak settings without having to change everything in world, and also so different characters could behave differently.

That said, there’s no reason you can’t modify GroundFriction based on physical material they are standing on, if they want to. There is “CurrentFloor” member of CharacterMovementComponent that among other things has access to physical material of surface character is on (through CurrentFloor->HitResult). One option would be to inspect this each update and change GroundFriction accordingly.

As for why character didn’t move when simulating physics, that is because you either get physics movement or movement through component, never a combination. It should move once you apply a physics force to capsule, if it’s simulating physics (although I also expect capsule would start falling over!).

Does current floor work for BSP? I’m not getting anything returning. Here’s my setup.

Is it working on things other than BSP?

First thing to check is that you set “ReturnMaterialOnMove” to true on your Character’s CapsuleComponent.

Hey Charlie,

As mentioned, make sure Return Material on Move is enabled in your Character’s CapsuleComponent. Current Floor will work for a BSP, but I don’t think you can put a Physical Material on a BSP. In any case where there is no Phys Mat, you’ll get DefaultPhysicalMaterial returned as Display Name. Your Blueprint should work fine if you set ReturnMaterialOnMove to true as suggested.

Ahh, perfect. That returns PhysMat. I created an Ice looking material. Then a Material Instance that hooks Material and PhysMat together. Then slapped MatInst on BSP. Works like a charm. Now to apply physics forces…

Thanks for help! Another question. I’ve implemented character movement tweaks when on “ice”. It works great when on flat ground, but if there is a slope, I would expect character to slide down slope. What’s best Character Movement attribute to play with to achieve this?

Nevermind, I figured it out. Basically I get normal of hit result. If Z is less than 1, then I take X value, multiply it my a constant (in my case 25), then add it to existing X velocity, and set velocity. Works well. Just posting my solution in case someone else stumbles upon this.

Some follow up. Basically I’m trying to make a wobbly iceberg that is also slippery. physical material check didn’t work on static mesh because I have to turn off static meshes collision and use collision component in Blueprint because I’m using a physics constraint to allow object to “wobble” in water.

If Static Mesh Component’s collision was enabled along with Box Collision Component, object freaks out.

To work around this, in Event Graph for object, I have a Set Physical Material Override node on collision component (not sure why we can’t set that in initial properties). There I set my desired physical material and result is joyous. If there’s a better way to get this to work, let us know.

You can give a Box Component a Physical Material in Details panel, but you’ll first need to create an empty Material that uses Physical Material. In Details panel, extend Shape section to reveal Shape Material setting. Apply your Material that uses your Physical Material, and that should work!

Of course, it sounds like you got it working pretty well without that. Let us know if you have other questions!

In case someone is still wondering how to make these slippery surfaces and at same time avoid allowing character to climb slopes, I did something pretty much like STAFF suggested, but didn’t have to mess with velocity functions though:

Did you post that video anywhere else? says it’s unavailable. If you still have it, I’d like to see it.

Ask u same.

So I’ve looked everywhere for a solution to this (how to move a player character with a dynamic object) and I can’t find jack. For example I have a normal third person character on a ledge and he gets slammed with a massive dynamic object but dynamic object just bounces off. I’ve tried so many fixes to this and nothing is working, getting very desperate.

Try using an impact event on character to get notified of hit, and then using either AddImpulse() or AddForce() on character movement component to affect velocity. You’ll want something like OnActorHit, OnComponentHit (for either capsule or mesh), etc.

If dynamic objects are simulating physics, you will need to set “Simulation Generates Hit Events” to true on physics objects (and collision in their physics asset) for events to be triggered.