Hi people, i’m developing a penalty kick game with panda3d + python, and i have a problem with a colision with the goal…
hi have this code…
Goal:
from pandac.PandaModules import *
class Baliza():
def __init__(self, game, name, yPosition):
self.model = game.loader.loadModel("models/goal")
self.model.reparentTo(render)
self.model.setScale(.025, .05, .03)
self.model.setX(.2)
self.model.setY(yPosition)
self.boundaries = {}
self.addBoundary(name,-370,0,-250,-370,0,250,10,(1, 0), (-1, 1))
self.addBoundary(name,370,0,-250,370,0,250,10,(1, 0), (-1, 1))
self.addBoundary(name,-370, 0, 250, 370, 0, 250, 10,(1, 0), (-1, 1))
def addBoundary(self, name, X1,Y1,Z1,X2,Y2,Z2,TAM, posOffset, velMultiplier):
boundary = CollisionTube(X1,Y1,Z1,X2,Y2,Z2,TAM)
boundary.setTangible(True)
self.boundaries[name] = [boundary, posOffset, velMultiplier]
colNode = self.model.attachNewNode(CollisionNode('goal' + name))
colNode.node().addSolid(boundary)
def collide(self, ball, boundaryName):
vel = ball.body.getLinearVel()
pos = ball.body.getPosition()
b = self.boundaries[boundaryName]
ball.body.setPosition(pos.getX() + b[1][0], pos.getY() + b[1][1], pos.getZ())
ball.body.setLinearVel(VBase3(vel[0] * b[2][0], vel[1] * b[2][1], vel[2]))
and in the Game:
(...)
elif fromName == "ballNode":#se for a bola
if intoName == "playerNode":
pass
elif intoName == "goalBlue" or intoName == "goalRed":
self.baliza.collide(self.ball, intoName)
(...)
And i have got the error:
Traceback (most recent call last):
File "Game.py", line 76, in updateScene
self.baliza.collide(self.ball)
AttributeError: 'dict' object has no attribute 'colide'
:task(error): Exception occurred in PythonTask updateScene
Traceback (most recent call last):
File "Game.py", line 100, in <module>
game.run()
File "dstroot/pythoncode/Developer/Panda3D/lib/direct/showbase/ShowBase.py", line 2531, in run
File "dstroot/pythoncode/Developer/Panda3D/lib/direct/task/Task.py", line 496, in run
File "dstroot/pythoncode/Developer/Panda3D/lib/direct/task/Task.py", line 454, in step
File "Game.py", line 76, in updateScene
self.baliza.colide(self.ball, intoName)
AttributeError: 'dict' object has no attribute 'colide'
Anyone can help me? what is this ‘dict’ object??
What is wrong? with the field is working fine…
Thanks a lot.