Collision Problem

when he hits head on the repellent force cant push it as far so your set its positions. Try setFluidPos position first then look closely how tutorial does it. ( I think there he just gets stuck on collisions which does not help you much)

Also look at the collisions we did in iron angels discourse.panda3d.org/viewtopic.php?t=3568
we did not use CollisionHandlerPusher and don’t realy know how well it works. “A specialized kind of CollisionHandler that simply pushes back on things that attempt to move into solid walls. This is the simplest kind of “real-world” collisions you can have.” Probably was not written to exactly handle you teleporting him around .4 units (which is alot in collision scales) .4 units per frame would make you fly outside the game range quickly. Using some thing more gentile like .01 per frame would probably work as i have it in my demo.

code showing this:

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *
from direct.task.Task import Task
from random import *
#initialize traverser
base.cTrav = CollisionTraverser()

#initialize pusher
pusher = CollisionHandlerPusher()

#########

#load a model. reparent it to the camera so we can move it.
smiley = loader.loadModel('teapot')
smiley.reparentTo(render)
smiley.setPos(0,0,0)
smiley.setScale(.2)

#create a collision solid for this model
cNode = CollisionNode('smiley')
cNode.addSolid(CollisionSphere(0,0,0,5))
smileyC = smiley.attachNewNode(cNode)
smileyC.show()

#########

#load a model
frowney = loader.loadModel('teapot')
frowney.reparentTo(render)
frowney.setPos(0,0,0)
frowney.setScale(.2)


#create a collsion solid for this model
cNode = CollisionNode('frowney')
cNode.addSolid(CollisionSphere(0,0,0,3))
frowneyC = frowney.attachNewNode(cNode)
frowneyC.show()

#########
#add collision node to the traverser and the pusher

base.cTrav.addCollider(frowneyC,pusher)
pusher.addCollider(frowneyC,frowney, base.drive.node())

#########

#have the one ball moving to help show what is happening
#frowney.posInterval(5,Point3(5,25-26,0),startPos=Point3(-5,25-26,0),fluid=1).loop()

def move(task):
    frowney.setPos( frowney.getPos() + Vec3(.01,0,0))
    if frowney.getX() > 5:
        frowney.setX(-5)
        frowney.setY(0)
        frowney.setZ(0)
    return task.cont
taskMgr.add(move, 'move')



#run the world. move around with the mouse to see how the moving ball changes
#course to avoid the one attached to the camera.

run()