Physics objects that don't affect the player

Hi,

I’m relatively new to Unreal, I’ve been using it for prototypes for about 12 months. I’m making a top down game with a few dozen physics objects active at any time, and a character that walks freely around the world.

How can I make the physics objects treat the player character like a solid object, but make the player character totally unimpeded by them?

Example 1, a ball should bounce off the player character as if they were a solid wall.

Example 2, the player character should be able to run through a stack of crates without even slowing down; the crates should disperse with natural forces from the collision

So I managed to solve this myself. Please any experts still let me know if there is a better way.

My solution:

  1. Add a second, slightly larger capsule as a child of the main player capsule
  2. Configure its collision presets to ignore world static, camera, visibility. This way the base capsule is still responsible for static world collision, and the second capsule doesn’t capture the camera spring arm
  3. Configure the collision presets on the base capsule component to ignore world dynamic objects and physics bodies

The player character can now run around freely, and other physics objects will be pushed away on contact. Here is a video of gameplay: https://youtu.be/4Wn0cuwkBn8

PusherCapsule is a slightly larger duplicate of CapsuleComponent, with CapsuleComponent as a parent.

312569-screenshot-2020-09-06-110806.png

Settings on the pusher capsule

Settings on the base CapsuleComponent

I cant figure out how to edit my question above, but I’ve got a partial solution that still has one glaring problem.

312569-screenshot-2020-09-06-110806.png

I’ve added an additional capsule that is slightly larger than the player capsule. This allows the player to move around and push larger objects exactly as I liked, but smaller objects make him totally wig out and teleport around.

I’m not sure what causes this to happen, but it seems to be when they get stuck underneath his capsule. He can teleport up to a few feet in random directions when it happens. I’ll see if i can make a video.

Are you saying that you want objects to be able to bounce of the character if they are shot at the player, but the player can walk through them otherwise?

Yes, exactly.

Although in this game the objects are mostly just laying around waiting to be sucked up, rather than being shot from a gun.

You could play with those settings and it could get you close to what you need (see their tooltips for more info) after a lot of trial and error, mostly error:

312589-annotation-2020-09-06-083440.jpg


But instead, you could have an additional capsule on your character dedicated to collision:

And you end up with this:

Image from Gyazo

Hey! Thank you for this, the capsule solution is actually exactly the solution I came up with myself about an hour after I posted the question. I did submit it as an answer, but it seems to have gotten stuck in limbo “waiting for moderation”.

It works great, but has a side effect that when you sandwich a physics object up against a solid wall, it teleports through the player character.

I didn’t know about the CharacterMovement component’s push force properties at all. I’ll play around with those tonight, maybe there’s a winning combination of settings in there to get this perfect without that one side effect.

Thanks so much for the answer!

You could try disabling this on the offending meshes:

It works great, but has a side effect
that when you sandwich a physics
object up against a solid wall, it
teleports through the player
character.

If it gets really obnoxious (especially for larger objects like the pillars you’re pushing around), you could try playing with these:

Their extended tooltips (ctrl+alt) explain the ups and downs of fiddling with the values.

But since we’re using a separate capsule here and:

it seems to be when they get stuck
underneath his capsule

Which explains it nicely; you could offset the capsule in -Z, so the round bottom bit sinks into the ground and smaller objects do not end up jammed in there. Or use a cylinder for collision.

Thanks again! That’s exactly what I ended up doing. I actually posted those comments four days ago. :-/

Oh! Thank you again! UE4 has so many great features like this buried in the components.