I am working on a simple project using the third person template that cames with unreal 5.1 as a starter, and am running into some issues that I can’t seem to identify.
I have my character which has a capsule collider on it, and then I have an enemy AI character that also has a capsule collider on it.
When I jump on top of the enemy AI, there’s a huge gap between the bottom of my feet and the top of the enemy I am jumping on. I have moved the skeletal meshes so that they are bigger than the colliders, and still there is a decent gap between them.
I am trying to achieve a clean surface to surface touch between the characters feet and the top of the enemy, or at least a smaller gap that can be covered with a particle effect.
I included a short video of the issue. You can see when I jump on the enemies head that I am not even close to touching the enemy and I bounce back (I have a launch character script in to launch when the player touches, but even with that disabled it does the same thing)
The characters are not interacting with each other on a skeletal mesh basis. Your collisions are probably based on the capsule collider around the characters.
You would probably need to switch to a per mesh collision disabling the capsule’s collision while in mid-air or make the capsule smaller while jumping to make the feet line up with the collision.
I have the collisions on both colliders to ‘overlap pawn’. Both characters ‘should’ be of the pawn class by inheritance so they shouldn’t be hitting each other, correct?
The meshes themselves are where the collision is set, and it’s set to block dynamic.
So it seems that I changed it from overlap pawn to block dynamic because the ‘on landed’ wasn’t working anymore after.
What I am going to try to do (and hopefully it works), is set the collider back to overlap pawn, and on the mesh itself use ‘on begin overlap’ and throw a line trace in the hit direction. If it’s straight down and it hits an enemy, do the death stuff for the enemy. If it’s straight down and not an enemy, do the on landed stuff (play the sound and particle effects). If it’s not straight down, see if it’s an enemy and damage the player.
That should cover all the bases (at least for now), and get it to somewhat work as I am expecting it to.
Just not sure how to check if the hit direction is directly ‘below’ the user.
Never mind, it seems even if you set the collider to overlap pawn it gets overwritten at runtime anyway (and goes back to block all dynamic) as it’s still doing the same thing (a huge gap between the player and the object it’s colliding with).
Seems silly that something built as a ‘template’ needs so much work to even be useable for basic things like jumping. I haven’t even gotten into advanced things and already am having issues getting it to work in any sensible way.
Was reading some articles online and it seems most people get around this limitation by inheriting from ‘pawn’ instead of ‘character’, and building their own movement scripts and collision detections.
I ‘could’ resize the cylinder when I start jumping, but that also seems extremely prone to bugs/issues (for example, how would I accurately know when to resize it back to it’s original size? I can’t use on landed, or the feet will go through the floor at first before the capsule is resized), and with the potential of enemies, crates etc being varied sizes it’s not like I can use time based or consistent sizing things to know when to resize it back.
After spending all weekend on this problem with no help in sight, I think I figured it out finally. It probably won’t hold up as more mechanics are added but it’s a starting place for now.
When the player jumps, I shrink the capsule collider by half. On tick, I check if the player is falling and if so, shoot a line trace exactly 25 units below the character (I did some trial and error to see how far down the players feet are when ‘standing’ to get the number). If it hits anything, it resizes the capsule collider to the normal height. So far it’s working a lot better, but we will see when more mechanics get put into place. I am also not sure how performant calling a line trace every tick is.