Note: I originally asked this question on the AnswerHub, but the forums might be a more appropriate place.
I’m totally new to the Unreal Engine way of things, but I do know that I’d like to make a 2.5D platformer game, and that I want to use a box for collision instead of a capsule due to literal edge cases (try walking off an edge in the side scroller tutorial; instead of falling, you’ll keep walking off the edge until the MyCharacterBP object runs out of curves to use to “stand up”).
After investigating the code a bit, I found that I would have to roll my own version of Character in order to replace the Capsule as a root component. Specifically, I copied and pasted the code, making a few adjustments here and there to account for the differences in the functionality between CapsuleComponents and BoxComponents. This initially caused a lot of issues with redefined code, which I solved by removing the offending code for now, but the current issue is that UE4 only seems to consider CapsuleComponents to be valid root components for actors. This seems really strange, but seems to be implied by the following lines of code in the engine:
LevelActor.cpp, line 667:
// currently just tests RootComponent. @TODO FIXME should test all colliding components? Cost/benefit? UPrimitiveComponent* PrimComp = TestActor ? Cast<UPrimitiveComponent>(TestActor->GetRootComponent()) : NULL;
// @TODO support more than just capsules for spawning, don't yet have - add primitive component function to calculate these, use boundingbox as fallback UCapsuleComponent* Capsule = Cast<UCapsuleComponent>(PrimComp);
I’ve spent almost all of the free time I’ve had over the last two days just trying to get this class to compile with box collision. I wanna make sure I’m not barking up the totally wrong tree here. Should I be doing something entirely different to get what I want? (essentially, no ability for the character to stand just below and off of a ledge; either they’re standing on the ledge or they are falling off of it, like in every single other platformer)
When I attempt to Play In Editor with a Blueprint that is a child of a class that inherits from my CustomCharacter class instead of the default side-scroller subclass, I get an assertion failure on line 690 of LevelActor.cpp.
Edit: To clarify, this is the situation that will inevitably happen in a 2d platformer:
In that situation, one of two behaviors can be defined depending on the Perch Threshold. Either the character slips down and falls, or the character stands at that height and can continue walking onto the platform. What I want (and what I would get from a box component) is for the character to stand, but at the height of the platform, rather than the point of the curve where the capsule meets the edge. That way, when he continues to walk onto the platform, he doesn’t move upwards at all, because he never would’ve been standing below the edge in the first place.