So i found some force based movement code iin the bullet examples and implemented it inmy game. I relaized tho that the force is not relative to the models hpr that i want to be moved. I wan the direction its facing be the forward direction etc.
def processInput(self, dt):
force = Vec3(0, 0, 0)
if inputState.isSet('up'): force.setZ( 1.0)
if inputState.isSet('down'): force.setZ(-1.0)
if inputState.isSet('left'): force.setX(-1.0)
if inputState.isSet('right'): force.setX( 1.0)
force *= 10
self.np.node().setActive(True)
self.np.node().applyCentralForce(force)
This lets the models move around but wheni change the models hpr(which i parented the cameras hpr to, so to turn you just move the mouse - like an fps cmaera/movement control. Imso bad at explaining things)Im terrible with vectors and i only barely grasp whats happening in this code. and vec3 cant be reparented to the model. Any help wuld be great lol
def processInput(self, dt):
force = Vec3(0, 0, 0)
force = render.getRelativeVector(self.np, 0)
if inputState.isSet('up'): force.setZ( 1.0)
if inputState.isSet('down'): force.setZ(-1.0)
if inputState.isSet('left'): force.setX(-1.0)
if inputState.isSet('right'): force.setX( 1.0)
force *= 10
self.np.node().setActive(True)
self.np.node().applyCentralForce(force)
No, this is not right. You have to transform it to global coordinates AFTER you have setup the force vector.
def processInput(self, dt):
force = Vec3(0, 0, 0)
if inputState.isSet('up'): force.setZ( 1.0)
if inputState.isSet('down'): force.setZ(-1.0)
if inputState.isSet('left'): force.setX(-1.0)
if inputState.isSet('right'): force.setX( 1.0)
force *= 10
force = render.getRelativeVector(self.np, force)
self.np.node().setActive(True)
self.np.node().applyCentralForce(force)