collision handler floor problem( now really solved )

Hi friends, my charater collision is weird, it slowly falls to the ground(right), but when it touches the ground, the charater starts to slide in the terrain, since the terrain is irregular(not flat), but it wasn´t supposed to happen, except in some special terrain types.

Maybe it is happening because it´s the collision sphere set as pusher which is doing the collision. Maybe I need to configure the ray collision somehow or create a new collision sphere to interact with ground, so the pusher sphere collider can avoid entering in contact whith the ground?

I will experiment here, but I would be gratefull for any help, since I´m kind of new to how Panda3d collision works

#This code is located inside a class
        #CREATE TRANSVERSER
        base.cTrav = CollisionTraverser()

        #CREATE THE PUSHER 
        base.pusher = CollisionHandlerPusher()

        #CREATE THE RAY AT BASE
        base.floor = CollisionHandlerFloor()
        base.floor.setMaxVelocity(1)

#This code is inside avatar class
    def createColliders(self):
        #SPHERE AS PUSHER
        self.playerSphereCN = CollisionNode("avatarSphere")
        self.playerSphereCN.addSolid( CollisionSphere(0,0,3, 2) )
        self.playerSphereNP = self.player.attachNewNode(   self.playerSphereCN )
        self.playerSphereNP.show()

        base.cTrav.addCollider( self.playerSphereNP, base.pusher )
        base.pusher.addCollider( self.playerSphereNP, self.player)

        #RAY FOR FLOOR
        self.ray = CollisionRay(0,0,-1 , 0,0,-1)
        self.playerRayCN = CollisionNode("avatarRay")
        self.playerRayCN.addSolid( self.ray )
        
        self.playerRayNP = self.player.attachNewNode( self.playerRayCN )
        self.playerRayNP.show()
         
        base.cTrav.addCollider( self.playerRayNP, base.floor )
        base.floor.addCollider( self.playerRayNP, self.player )

Hey, and if you could exemplify with code it would be great too

if you apply gravity onto a physical object it will automatically slide if the ground is not completely flat. most computer games dont make the player character a real physical object, it only has a physical collider which influences other objects (like pushing boxes).

if you want to keep your physical character, you could for example calculate the steepness of the ground and fiddle with the physics so it doesnt add the force if it’s too small…

Well, I? was reading about collision handler floor in Panda3D manual, and notice this:

well…there is no shame in asking, so, can anyone give me a code example about how to use ray, collisionhandlerfloor and aditional code(probably needed) to make a ray detect the ground, drop the object slowly to the floor, yet stopping when the object has touch the ground like the manual say to be possible?

Thanks for any help, I will post the solution when I reach it as usual

I guess that line is your problem:
self.ray = CollisionRay(0,0,-1 , 0,0,-1)

base.myTraverser = CollisionTraverser()

base.floor = CollisionHandlerFloor()
base.floor.setMaxVelocity('value')

self.ray = CollisionRay(0,0,2 ,0,0,-2)
self.rayColl = CollisionNode('PlayerRay')
self.rayColl.addSolid(self.ray)

self.playerRayNode = self.yourModel.attachNewNode( self.rayColl )
self.playerRayNode.show()

base.myTraverser.addCollider (self.playerRayNode, base.floor)
base.floor.addCollider( self.playerRayNode, self.yourModel)

EDIT:
[b]ray = CollisionRay(ox, oy, oz, dx, dy, dz)
oz = Z origin dz = Z direction( - point down, + point up )

setOffset ( Z value )

setMaxVelocity( values up to 50 are slow, up to 100 a little fast, above 100 I haven´t tested )[/b]

The sphere set as pusher, in contact with ground just did what it was meant to do, so it considered the floor a wall too and consequently made the charater slide in it at high speed.

Then, I deactivated the sphere set as pusher, letting only the ray activated for testing purposes. I used the default [b]Z origin/b and set the ray pointing down ( - ). The charater fell too slow, and the charater was partially sunk into the ground.

Solution? I set setMaxVelocity to 100( not instantly falling to the ground, but close ) and setOffset to 6.5. That offset was enough to keep my charater above the ground, like it should be. The pusher sphere isn´t in contact with the ray, so the charater isn´t rocket lauching anymore.

Zephyro, the problem wasn´t the the Z origin being - 1, it does not matter at all in this problem.

All is working now. Kind of got excited since I thought to have solved the problem before, sorry. Now this is the real fix for those with equivalent problem.

Now really thanks to all which helped me here. Making mistakes and learning isn´t it?