I’ve been trying to build a sidescrolling platformer (something like classic mario or metroid) and, for reasons like being able to have a custom collision box and being able to simulate gravity with more control, I am using a pawn class instead of the character class. And since the pawn class does not inherit any movements or gravity, I had to add those in. I added in my own simulated gravity by applying a constant downward offset. It works fine until the pawn is grounded. The problem is that once it collides with the floor, gravity needs to ‘turn off’ or the pawn will constantly collide into the floor which causes the pawn to not be able to move horizontally at all.
I have attempted fix this by using OnComponentHit and turning off the gravity offset as soon as the pawn collides with any object (I only have generic floor objects right now). While this allows the pawn to move horizontally once it is on the ground, there is now no gravity for when it walks off a ledge afterwards. So I need a way to turn gravity back on once it is airborne again.
I think that perhaps putting something like a hit box or maybe some kind of line tracing underneath my character to detect if there is floor or not and have a boolean like “IsOnFloor” or something is the best way to go about it. However I am unfamiliar with setting up collisions and there doesn’t seem to be too much documentation on how the ComponentOverlaps / ActorOverlaps / BeginOverlap etc… so any suggestions is helpful and appreciated as I am still just learning to use UE4.