So here is more what I was talking about. The periods represent the code already in there. Hope its not too confusing.
#imports
.
.
.
from direct.showbase.PythonUtil import closestDestAngle
.
.
.
class Picker(DirectObject):
def __init__(self):
.
.
.
#after self.player has been set up
self.npLook = self.player.attachNewNode("npLook")
.
.
.
def moveToPosition(self):
# Get the clicked position
self.getPosition(base.mouseWatcherNode.getMouse())
# Calculate the new hpr
self.npLook.lookAt(self.position) # Look at the clicked position.
currHpr = self.player.getHpr()
newHpr = self.npLook.getHpr(render)
newH = closestDestAngle(currHpr[0], newHpr[0])
# Create a turn animation from current hpr to the calculated new hpr.
playerTurn = self.player.hprInterval(.2, Point3(newH, newHpr[1], newHpr[2]))
# Calculate the distance between the start and finish positions.
# This is then used to calculate the duration it should take to
# travel to the new coordinates based on self.movementSpeed
travelVec = self.position - self.player.getPos()
distance = travelVec.length()
playerMove = self.player.posInterval((distance / self.movementSpeed), self.position, startPos = sPos)
self.playerMovement = Sequence(playerTurn, playerMove)
self.playerMovement.setDoneEvent('player-stopped')
# Start the walking animation, then start the turn+move anims
self.player.loop('walk')
self.playerMovement.start()
.
.
.