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:
Add a second, slightly larger capsule as a child of the main player capsule
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
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.
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?
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:
But instead, you could have an additional capsule on your character dedicated to collision:
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.
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.