Closed burnie5749 closed 3 years ago
Is self.player
an instance of the PlayerController
? If so, you should better use the self.player.plugin_setPos(newPos)
function which was made for external positioning.
yes self.player
is an instance of PlayerController
. Does the function allow for the character to move forward at a slow pace? I have just done a small bit of testing using that function and i can't seem to get it to work, it just puts the player further into the scene
It doesn't matter how fast your character moves, the position will be set to the new location.
You probably have to pass another object as your relative object for the position calculation since the characterController isn't the actual node that should be used. Here's a small working example for the placement code. You can see the use of the playerController.main_node
there for the position calculation.
I'll probably change the plugin_setPos
function sometime later to accept the same arguments as setPos
, but for now you have to do it like this to set the position correctly.
def moveCharacter(self, task):
dt = globalClock.getDt()
oldPos = self.playerController.plugin_getPos()
np = NodePath("temp")
np.setPos(oldPos)
np.setPos(self.playerController.main_node, 0,-2*dt,0)
self.playerController.plugin_setPos(np.getPos())
np.removeNode()
return task.cont
Hope that helps you.
That helps a lot! Thank you
When moving the player using
def movePlayer(self, task): dt = globalClock.getDt() self.player.setPos(self.player, 0,self.playerSpeed*dt,0 ) return task.cont
the collision sphere of the character does not follow the player model, how do I stop this from happening?