def enter(self, startTrack = None, playRate = None): StateData.StateData.enter(self) self.notify.debug('Walking ' + self.character.getName() + '... from ' + str(self.walkInfo[0]) + ' to ' + str(self.walkInfo[1])) posPoints = CCharPaths.getPointsFromTo(self.walkInfo[0], self.walkInfo[1], self.paths) lastPos = posPoints[-1] newLastPos = Point3(lastPos[0] + self.offsetX, lastPos[1] + self.offsetY, lastPos[2]) posPoints[-1] = newLastPos firstPos = posPoints[0] newFirstPos = Point3(firstPos[0] + self.oldOffsetX, firstPos[1] + self.oldOffsetY, firstPos[2]) posPoints[0] = newFirstPos self.walkTrack = Sequence(name=self.character.getName() + '-walk') if startTrack: self.walkTrack.append(startTrack) self.character.setPos(posPoints[0]) raycast = CCharPaths.getRaycastFlag(self.walkInfo[0], self.walkInfo[1], self.paths) moveTrack = self.makePathTrack(self.character, posPoints, self.speed, raycast) if playRate: self.walkTrack.append(Func(self.character.setPlayRate, playRate, 'walk')) self.walkTrack.append(Func(self.character.loop, 'walk')) self.walkTrack.append(moveTrack) doneEventName = self.character.getName() + 'WalkDone' self.walkTrack.append(Func(messenger.send, doneEventName)) ts = globalClockDelta.localElapsedTime(self.walkInfo[2]) self.accept(doneEventName, self.doneHandler) self.notify.debug('walkTrack.start(%s)' % ts) self.walkTrack.start(ts)
def enter(self, startTrack=None, playRate=None): """ startTrack, allows us to prepend a track to the walk tracks (such as a stand up). playRate, sets the play rate for walk. start walking, create intervals to make the character move from start to destination """ StateData.StateData.enter(self) self.notify.debug("Walking " + self.character.getName() + "... from " + str(self.walkInfo[0]) + " to " + str(self.walkInfo[1])) posPoints = CCharPaths.getPointsFromTo(self.walkInfo[0], self.walkInfo[1], self.paths) lastPos = posPoints[-1] newLastPos = Point3( lastPos[0]+self.offsetX, lastPos[1]+self.offsetY, lastPos[2]) posPoints[-1] = newLastPos firstPos = posPoints[0] newFirstPos = Point3( firstPos[0]+self.oldOffsetX, firstPos[1]+self.oldOffsetY, firstPos[2]) posPoints[0] = newFirstPos self.walkTrack = Sequence(name = self.character.getName() + '-walk') if startTrack: self.walkTrack.append(startTrack) # Ensure we are placed at the beginning of the path before we # start the track. This will put the character at the right # place even if the timestamp is way stale. self.character.setPos(posPoints[0]) raycast = CCharPaths.getRaycastFlag(self.walkInfo[0], self.walkInfo[1], self.paths) moveTrack = self.makePathTrack(self.character, posPoints, self.speed, raycast) # make the walking animation and lerping happen at the same time if playRate: self.walkTrack.append(Func(self.character.setPlayRate, playRate, 'walk')) self.walkTrack.append(Func(self.character.loop, 'walk')) self.walkTrack.append(moveTrack) doneEventName = self.character.getName() + 'WalkDone' self.walkTrack.append(Func(messenger.send, doneEventName)) ts = globalClockDelta.localElapsedTime(self.walkInfo[2]) self.accept(doneEventName, self.doneHandler) self.notify.debug("walkTrack.start(%s)" % (ts)) self.walkTrack.start(ts)