Physics collision bunny hop problem

Hello,

While building my game i got very annoyed by the collision registration of the floor(s) of the object(s).
If the character is passing over the physics line it’s getting launched into air (0.2 max hight).

Is there a good way to fix this?

I made a workaround for it but that is delaying my animation switching and you can see the character still getting bugged but the animations stays how it should be.

Video shows it all:

#Solved
I have solved my problem by making my ground sensor cube bigger on Z axis and placed it lower, i have put the player on compound collision.

result:

This has been an issue in the BGE since the 2.4x days and it’s unlikely that it will ever be fixed (in the vanilla version at least, it’s possible that the UPBGE people can fix it providing the Bullet Physics Engine has a way to avoid it now).

Yeah, test it in UpBge too.

to avoid this problem my actors actually walk, and I don’t encounter it anymore
(the feet alternate the contact points)

for things that ‘slide’ I recommend using a ray and staying just above the terrain and faking your own friction.

That must be the most elaborate workaround to a basic engine issue I’ve ever seen.

It’d be like if you came to a bridge (but you can’t drive your car over it because it’s too weak), so you drive to the nearest port, drive your car onto a cargo ship, and take a one thousand mile journey to another port from where you don’t have to cross said bridge to your destination.

Now you did suggest something a tad simpler at least.

it’s atually pretty easy to rig up a armature with compound physics child shapes that update each frame, and it also makes for a really nice hitbox

Well BPRs technique is not just a work around. There are lots of benefits to that system (like ease of adding footprints). He’s just mentioning that he doesn’t have the jumpy physics problem because he uses a different method.

As a more direct solution I recomend using a sphere collision box with dynamic physics type (not rigid body) and a servo motion actuator. That fixed all my physics problems.

These days however I usually work with python and no physics (a grid based system).

Well BPRs technique is not just a work around. There are lots of benefits to that system

This could be, but i am a total disaster if it comes to characters, animating is a pain already with IK’s it always messes up the bones/positions, if you don’t limit bones, IK has no use, if you limit bones, you cant even get a weapon from your back lol, without spending hours rotating bones and the ik to get to the right position. or with IK simple actions makes arm rotate a few times on its axis before it reach the position. So in other word i will look into it, but at a later stage.

I have seen your videos at resource BPR (globally looked at em all) but still wonder some things haha, but that wil get attention when i am at that stage.

At this point i am doing my character, so the bunny hop is very noticeable, but i managed to build a work around, that will fix the hopping and slope jumping (when you run up a slope onto a flat ground you get launched).


        ray_check   = cont.sensors['ray_check'] # (no true pulse needed -z direction)
        
        if ray_check.positive: 


            # distance to object below, from first checkpoint(my case a ground senor cube)
            # also the bunny hop check
            distance = own.children[0].getDistanceTo(ray_check.hitPosition)
            
            # distance the physics hop is.
            if distance > 0.05 and distance <= 0.20:
                
                # at this point your character cannot jump anymore, to fix add the biggest distance above 
                # to your jump action, like this example:
                
                # if jump: (example code)
                    # own.localPosition[2] += 0.21 (so your jump starts higher then the hopping check)
                    # z = jump_speed 
                
                # distance to object below, from second checkpoint(my case a player cube)
                distance2 = own.getDistanceTo(ray_check.hitPosition)
                
                #set the player cube position back to the ground, z axis with a  0.01 offset else you fall trough the floor.
                own.localPosition[2] = ray_check.hitPosition[2] + (distance2 - (distance + 0.01))
                
                
            else:
                own['action'] = 'moving'
                own['player_action'] = 'jumping'


I suggest to change the “on ground” detection.

A) use a ray to measure a short distance below the character
B) use a sensor object to measure the area below the character (could even be parented to the foot bones).

I would not immediately play the fall animation. It looks really strange on small falls. The above mentioned methods should already solve that. Additionally you can use them to differentiate between little and large falls.

I hope it helps

I suggest to change the “on ground” detection.

A) use a ray to measure a short distance below the character
B) use a sensor object to measure the area below the character (could even be parented to the foot bones).

I would not immediately play the fall animation. It looks really strange on small falls. The above mentioned methods should already solve that. Additionally you can use them to differentiate between little and large falls.

I hope it helps

I use a sensor cube below player box that detect ground collisions (the ground check). Then when it is NOT positive i check the distance with a ray. So the sensor is the detector of walk able surfaces and the ray is used to check the bunny hop and falling.

Also i only have 1 animation that represents falling and jumping (just for some visuals while building/moving).

But to be real honest its a pain to build a work around for basic options. it just bounce at every physics line there is.
sometimes the character even stops moving and i need to re press the key to start moving again (they really should fix this issue)

Bge is on-hold or left dead. So if you want something fixed ask the UPBGE devs. Nothing is going to get fixed if the devs dont know about it!

In this case though, it may or may not be due to an issue that was never fixed in the Bullet engine itself, not the BGE.

If the former, then the best the UPBGE devs. will be able to do is commit a hardcoded workaround, because the task of fixing it properly falls on the Bullet developers.

I think most games out there using bullet that are professional dissolve the triangle mesh terrain into many convex hulls using a algorythm,

also I think they have a seperate list of colliders and game objects, (so adding a bunch of colliders to a scene does not bloat the total game object count)

about walking physics armatures,
you just parent empties to each bone(bone tags), and then make a simple physics bound like a cube that’s origin rests at the bone tag and the rotations of the child shape match the empty(child shapes).

parent the child shapes to a ‘root’ object and also parent the armature to the root,
root needs a simple bound(cube etc) and compound checked.

set the names to something like

childshape_left_upper_leg

bonetag_left_upper_leg and add the property ‘boneTag’ to each empty
set the value of bonetag to a string that is the corresponding childshape,

and then you do this on frame0

import bge
cont = bge.logic.getCurrentController()
own=cont.owner


if 'boneList' not in own:
    BL =[]
    for child in root.childrenRecursive:
        if 'boneTag' in child:
             BL.append([child,own.children[child['boneTag']]])
    own['boneList']= BL

for bone in own['boneList']:
    bone[1].removeParent()
    bone[1].worldPosition=bone[0].worldPosition
    bone[1].worldOrientation=bone[0].worldOrientation
    bone[1].setParent(root,1,0)
 

Bge is on-hold or left dead. So if you want something fixed ask the UPBGE devs. Nothing is going to get fixed if the devs dont know about it!
keep promoting it, i am not using it, so you may pass it onto them if you like. Sad to hear that it is on hold.

about walking physics armatures,
you just parent empties to each bone(bone tags), and then make a simple physics bound like a cube or thats origin rests at the bone tag and the rotations of the child shape match the empty(child shapes).

Ok ill take a shower and going to try it that way.

ok, after you get it working, as he moves forward, make sure the animation rate matches the amount moved, and ‘snagging’ will ever happen, as the foot planting the weight is stationary relative to the ground,

ok so i just need to make sure that the feet hit the ground in the animation?
because now i got this, it works but as you said its screwing up the animations.

also if i jump from a height it jumps trough the floor(maybe feet boxes bigger helps). so alot of other problems to solve.

#edit
ok bigger boxes dont help, and also tested the hopping and it still exist,
oh and i needed to switch the 0 and 1 at the bones :wink:

You see im only trying to help.

pm me a .blend and I will take a look

edit:
if the rate of movment is greater then the speed of the walk motion you can still get pop

about the poping through, if you don’t use many convex hulls or simple physics bounds for the ground you may need home made ccd using rays extending down from the feet based on linV…

triangle mesh has 0 thickness so if you move fast enough you pop through
(using rays you can detect this will happen 1 frame early, and set the position based on the hitpoint next frame and remove linV)

your ground needs to be at least as thick as the feet to avoid problems.

hmm, my character is using human speeds, walk speed = 2, run speed = 5.
I actually have solved the problem with my ground sensor and the player box.

I placed it lower made it bigger on z axis, put player on compound collision (nice option haha) now every problem i had is gone, there is no ray usage only a ground sensor cube with collision senor.

Take a look:

#edit
as you can see i dont even get launched anymore where the hop was, even that is gone.