If moveVector gets zeroed every frame, and as a consequence newVector as well, what is the point of getting the velVector if it’s going to print the same as newVector? We know that a previous zero length vector will have that effect… I don’t know what to do, quite honestly. I thought that in theory I had nailed it, that I needed to set a destination (newVector) vector so that I could add it to a current Vector (more like the previous frame one) in order to get a velocity vector and use it to accelerate or decelerate the character everytime I pull a new direction (wider angles between the old and new vectors should accelerate us more than tighter angles, for example, because their sum gives us a vector whose length we can get). The problem is: the vector getting zeroed every frame not only doesn’t allow me to save it with setTag or setPythonTag, nor does it allow me to get a previous vector other than Vec3(0,0,0).
def move(self, task):
base.camera.lookAt(self.ralph)
if (self.keyMap["cam-left"] != 0):
base.camera.setX(base.camera, - 15 * globalClock.getDt())
if (self.keyMap["cam-right"] != 0):
base.camera.setX(base.camera, + 15 * globalClock.getDt())
startpos = self.ralph.getPos()
self.moveVector = Vec3()
if (self.keyMap["left"] != 0):
self.moveVector.setX(-1)
if (self.keyMap["right"] != 0):
self.moveVector.setX(1)
if (self.keyMap["forward"] != 0):
self.moveVector.setY(1)
if (self.keyMap["backward"] != 0):
self.moveVector.setY(-1)
self.newVector = render.getRelativeVector(base.camera, self.moveVector)
self.newPoint = startpos - self.newVector
if self.newVector.length() > 1:
self.newVector.normalize()
self.newVector *= 5
self.newVector *= globalClock.getDt()
self.ralph.setFluidPos(self.ralph.getPos() + self.newVector)
if self.moveVector.length() != 0:
self.ralph.lookAt(self.newPoint)
self.velVector = self.ralph.getPosDelta()
What could I do with this?