Booster, Physics

hey again all…not getting sick of me yet are you :stuck_out_tongue:

i want to add boosters to the object in my game so for example if you press spacebar it will accelerate at a greater rate until you release the spacebar

i know the easiest way to go about this would be to adjust my maxSpeed variable and then readjust it when you release the spacebar but i really really want to try to use the physics system for it so i’ve followed david’s smiley physics example and managed to get a linear force to act on the object but there are 2 problems

  1. i can’t get the linear force to always act in the direction the sub is facing so you don’t boost sideways for example hehe

  2. i have a camera task which follows the object as it moves in the game but when i introduce the force the camera doesn’t follow the object as it moves with the force but acts as though the object is still in the place it was prior to movement.

any ideas?

the camera task looks something like this

def changeCamera(self,task):
		dist = 30.0
		angle = self.object.getH()*math.pi/180.0
		dx = dist * -math.sin(angle)
		dy = dist * math.cos(angle)
		base.camList[self.playerNumber].setPos(self.object.getX()-dx, self.object.getY()-dy, self.object.getZ())
		base.camList[self.playerNumber].lookAt(self.object.getX(), self.object.getY(), self.object.getZ())
		return Task.cont

so i’m guessing with the 2nd problem the x,y,z coordinates aren’t being updated when the force is applied…?

with the first issue it’s a matter of calculating the x,y,z components of the force but will these be updated at each time step so that even if i turn the object while the force is applied that the force will be adjusted as well? any help with the math would be greatly appreciated :smiley:

does anyone have any idea?

i managed to get it to move within the sub’s coordinate system just by rearranging the way the node is attached but i still have the problem with the camera and then when i press the boost button again for some reason the sub “resets” and starts at that same position again…