Change/get rid of default capsule component?

I started with the 2D side scrolling template and noticed it’s using a capsule for collision. I’ve got a blueprint that has a flipbook in it (much like the example).

I’m making a top down shooter and don’t want a capsule for collision…I want the ship always remaining aloft and not falling to the ground and I’d like to use a different, tighter shape as a hit box. I can’t see a way to either remove the capsule, or to essentially “ignore” it. I noticed that if I change the collision presets to NoCollision I fall through the scene. I also don’t seem to be able to set the capsule’s half-height to anything less than 100. Any ideas on how to approach this? Thanks.

I know what you are talking about. I am making a side scrolling 2D shooter. The acharacter class has gravity, but you can disable the gravity by putting the gravity variable to 0.0f. I had the same issue as you and ended up using the top down shooter with the little spaceship as my starter template. It uses a pawn so there are no gravity issues. Also you do not need to have a collision box .

Hi,

This is what the FObjectInitializer is for.
In the constructor of your class, instead of doing the call:

Super(ObjectInitializer)

change it to

Super(ObjectInitializer.DoNotCreateDefaultSubobject(ACharacter::CapsuleComponentName))

You might have to change some more code in your constructor to setup your new root component and reattach components to your root.

I haven’t looked into this too much, so there might be a way to actually change what type of component it should spawned with the ObjectInitializer. Try checking it’s other functions.

Cheers,

Alright I took your advice after some digging around that seemed like removing the capsule was a bad idea. The problem for me was that I’m using a Paper2D flipbook so I was confused at first as to how to go about doing it since from the Paper2D example it makes your character derive from PaperCharacter which derives from Actor.

What I did was made my ship derive instead from APawn. I then copied what PaperCharacter does and added this to my ship’s header file:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Animation, meta = (AllowPrivateAccess = "true"))
class UPaperFlipbookComponent* ShipDefaultAnimation;

I then copied most of the lines from PaperCharacter.cpp’s constructor (please see the source, it’s too much to post) obviously replacing the reference to “Sprite” with my own flipbook component. I also didn’t do the line that says:

Sprite->AttachParent = RootComponent

Instead, I did:

RootComponent = ShipDefaultAnimation

to replace the root component with the flipbook component so I didn’t have some random empty scene component in my blueprint. Then I just did a ->SetFlipbook on my ship animation and I was all set. No more capsule, no more gravity, no more weirdness, and the rest of my movement and visuals looks the same. Thanks for the inspiration!

awesome to hear! The thing I noticed though if you make your object the root component, there are no transform options like rotate and location :frowning:

That’s true in the blueprint editor but I don’t seem to have an issue moving my player around in code via RootComponent->MoveComponent(…)

Edit: To get around that I just made a dummy scene component:

RootComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("Scene"));

Then did:

ShipDefaultAnimation->AttachParent = RootComponent;

Now it’s all good and as an added bonus I can rotate/scale/translate in the BP editor which I suppose is a handy feature.

Hello, this isn’t working for me. Has anything changed? (using UE4.15.2)