collide error

Hi, i’m still trying to get collision in my game to work XD I tried using examples to help me getting collision but for some reason it still wont work, or part-ly wont work. I get the walls working but the floor wont seem to “push” back the camera and I also get the following error-?

:util(warning): Adjusting global clock's real time by 1.81198e-005 seconds.
:collide(error): Invalid points in CollisionPolygon:
  160.585 -17320.2 1175.5
  151.585 -17329.2 1157.5
  157.585 -17323.2 1169.5
  normal 2 0 0 with length 2
:collide(error): Invalid points in CollisionPolygon:
  -352.415 -17323.2 956.501
  -340.415 -17329.2 950.501
  -346.415 -17326.2 953.501
  normal 0 -0.03125 0.5 with length 0.500976
:util(warning): Adjusting global clock's real time by -17.2893 seconds.

I am also turning my .x files into .egg files so i’m not sure if thats what is messing up the collision. userdefined1002 is all the things in my map under one thing so I didn’t have to keep typing out { Polyset keep descend } over and over again.

<Group> userdefined1002 {
  <Collide> { Polyset keep descend }
  <VertexPool> userdefined1002 {
    <Vertex> 0 {
      832 -192 -5888
      <UV> { -3.25 0.25 }
      <Normal> { -0.57735 0.57735 0.57735 }
more down the line-

As for the code here it is…

    def Collisions(self):
        base.cTrav = CollisionTraverser()
        base.pusher = CollisionHandlerPusher()
        self.cn = CollisionNode('player')
        self.cn.addSolid(CollisionSphere(0,0,0,2))
        self.solid = self.node.attachNewNode(self.cn)
        base.cTrav.addCollider(self.solid,base.pusher)
        base.pusher.addCollider(self.solid,self.node, base.drive.node())
        # init players floor collisions
        self.ray = CollisionRay()
        self.ray.setOrigin(0,-.5,0)
        self.ray.setDirection(0,-.5,0)
        self.cn = CollisionNode('playerRay')
        self.cn.addSolid(self.ray)
        self.cn.setFromCollideMask(BitMask32.bit(0))
        self.cn.setIntoCollideMask(BitMask32.allOff())
        self.solid = self.node.attachNewNode(self.cn)
        self.nodeGroundHandler = CollisionHandlerQueue()
        base.cTrav.addCollider(self.solid, self.nodeGroundHandler)
        base.cTrav.setRespectPrevTransform(True)

I see a small typo that’s making it complain about those two polygons, which are otherwise valid (though that large Y coordinate is weird). I’ll fix the typo.

This probably has nothing to do with why the rest of your code isn’t working, though.

Why do you set your ray’s origin to 0, -0.5, 0? And the direction to 0, -0.5, 0? That appears to be pointing horizontally, straight backwards. If that’s your only from solid, of course it will never detect the floor that way.

David

I dont know fully, it seem to work better when they was set like that with my map walls (didnt have gravity at the time, or just moving up and down). I was just looking at tuts in the example (cus i’m a total newbi at this collision stuff) and came up with the code from treeform and Roaming-Ralph. I think the only differnts they have to my maps is that they set their maps to “Z-up” and mine is like “Y-Up-Left” so wasnt 100% sure how to change the code to take this in. I did try chaning my Y-Up-Left to Z-up but then it changed the walls and floor around making the floor collision and my walls nothing.