Collision Event when nothing appends!

Hi everyone,

I have a problem with my collision system.

I have 2 collisions spheres.

One is around a planet and the other is around a spaceship.

I’m able to catch the collision in normal behavior
(when the spaceship REALLY hit the planet) but something strange is happening before that.
As soon as my game start, 2 collisions are detected. But what is strange is that my spaceship and my planet didn’t move. So everytime my game start, this event is catch and my spaceship explode for nothing…

So I was wondering if anyone here already have this issues.

Here is the code from my collision class:

from random import *
import os
from direct.task import Task
from direct.showbase.DirectObject import DirectObject
import direct.directbase.DirectStart
from pandac.PandaModules import *
import math

class CollisionDetection:
    def __init__(self,world): = world
        self.queue = CollisionHandlerQueue()
        self.traverser = CollisionTraverser()
        taskMgr.add(self.collisionTask, 'collision task')
    def addFromNodePath(self, nodePath):
        self.traverser.addCollider(nodePath, self.queue)
    def removeFromNodePath(self, nodePath):
    def collisionTask(self,task):

        entries = self.queue.getNumEntries()
        for i in range(entries):
            entry = self.queue.getEntry(i)
            #print entry
        return Task.cont
    def findIntoNodes(self, colEntry):
        fromNode = colEntry.getFromNodePath()
        intoNode = colEntry.getIntoNodePath()
        self.normal = colEntry.getSurfaceNormal(render)
        self.point = colEntry.getSurfacePoint(render)
        intoType = intoNode.getNetTag('collisionType')
        fromType = fromNode.getNetTag('collisionType')
        if (intoType == 'planet'): self.handlePlanetCollision(intoNode, fromNode, fromType)    
    def handlePlanetCollision(self, intoNode, fromNode, fromType):
        if fromType == "fighter":
                print "The fighter collide"
           except KeyError,e:
              pass # pro 

Don’t hesitate to ask question, I can provide more code.



Are you sure that your spaceship and fighter are not overlapping (for instance, both at 0, 0, 0) the first time you call collisionTask?


Ohhh I didn’t think of this…

Is it possible that during the loading ( a lot of things loads at the same time), my object appears at the center or maybe “move” to the direction I give him?

If it’s the case, what do you suggest me to know when everything has finish to load? A simple interval of a couple of second before starting the collision task?

Thanks for your help


I check my code this morning and since they were neve in contact, I guess that sometime in the loading, they move and collapse BEFORE I can see anything.

I put a timer of 5 seconds before my collision detection system start and everything is ok now. If anyone have a better idea like detecting when everything is loaded that could be a better idea but for now it’s ok.