Download

Replacing capsule for non vertical character

Hi, I have an four-legged animal character blueprint (having a C++ base class) for which the default vertical shape of the capsule doesn’t fit (and the shape of the capsule cannot be made horizontal, UE 4.16.2). I searched for posts about how to workaround the problem, but I only found partial information and this is still not working for me. So first thing seems to be using a box collision component to define the collision instead of the capsule. This is what I did, I scaled the capsule down, removed its collision settings, added a box collision to the blueprint hierarchy (under Capsule since this is the root component…) and set it up for collision. Result: collision not working, character falls through the floor. Second attempt, I read that it may help to make the box collision the root component (i.e. as replacement of the capsule). So I did this in the C++ base class of my character blueprint:



.h file:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup, meta = (AllowPrivateAccess = "true"))
	class UBoxComponent* BoxCollisionComponent;

.cpp file:

MyCharacter::MyCharacter()
{
 	PrimaryActorTick.bCanEverTick = true;
	
	BoxCollisionComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision"));
	BoxCollisionComponent->InitBoxExtent(FVector(5.1875f, 0.875f, 2.1875f));
	BoxCollisionComponent->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);

	BoxCollisionComponent->CanCharacterStepUpOn = ECB_No;
	BoxCollisionComponent->bShouldUpdatePhysicsVolume = true;
	BoxCollisionComponent->bCheckAsyncSceneOnMove = false;
	BoxCollisionComponent->SetCanEverAffectNavigation(false);
	BoxCollisionComponent->bDynamicObstacle = true;

	RootComponent = BoxCollisionComponent;

       // reparent the capsule
	GetCapsuleComponent()->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
}


Using this, the root is properly replaced by the box collision comp. But my character is still falling through the floor… Also, i cannot see the box collision in the Blueprint editor, so it is difficult to size it. For this I had to create a temp. collision box component under the root, scale it then I copied size values into the C++ constructor (InitBoxExtent) and removed it.

So my questions:

  1. am I on the right track? Do I really need to make the box collision comp. as root?
  2. what I am missing since I still have my character falling through the floor after adding the box collision component as root?
  3. how can I see my box boundaries/position into the Blueprint editor once I have it set as root comp?

Thanks!

It looks like I am not alone having troubles with the capsule and more generally ACharacter meant only to handle vertical characters, see this thread.

Character Movement Component can only work with Capsules, so if you do this you’ll still have to write your own Movement Component.

I think being able to rotate the capsule 90° would be the only thing I would need. But current engine code does not support this. This would also be useful for bipeds when crawling.

Thanks eyoli for your support. I am currently just using a hugely over-sized capsule for the character’s collision. Unfortunately, this means the character can’t fit through openings that are only as tall as the character, unless you modify the capsule size in realtime. You can use a smaller capsule to permit fitting through small openings, but then large appendages on the character will have no collision with static objects, even if you add additional collision capsules to these areas set to block all. However, this technique seems to work fine for blocking dynamic objects, but most of the environment must be made up of static objects. Not even blocking volumes can stop character penetration with the static world… only the single default capsule will do this!

I think Epic need not be afraid of implementing this change due to backwards compatibility. Simply make a separate, NEW character class that implements the adjustable collision or make a NEW character movement component that works with any class and keep the old versions in place for backwards compatibility. :cool:

I am in the exact same spot, did anyone figure this out?

The code of the Character Movement expects the capsule to be vertical in order to work, so even if you could rotate it most of the movement code would stop working.

You need your own movement component if you want a different type of updated primitive. Either way the updated component still has to be the root component, and since the root component cannot have relative rotation, the only alternative would be a box.

have you tried blocking the collision of mesh…click on mesh…and block all the collision by setting up coustom event. if you need something to discuss…then contact me -