Ejemplo n.º 1
0
	def __init__(self, game, charNP=None):
		kinematicCharacterController.__init__(self, game)
		self.name = "Player"
		
		"""
		See the KCC file
		"""
		self.setCapsuleData(1.85, 0.8, 0.3, 0.35)
		
		"""
		Set how high above the character's feet the camera is while standing and while crouching.
		"""
		self.setCameraHeight(1.60, .75)
		self.cameraHeight = self.crouchCameraHeight
		
		self.setMovementSpeeds(2.6, 5.2, 6.5)
		
		self.isSitting = False
		self.isDisabled = False
		
		"""
		This holds the camera smoothing animation
		"""
		self.cameraSteppingAnim = None
		
		"""
		I've decided to split that stuff into a couple more methods to make the code more manageable.
		"""
		self.setupTriggerInput()
		self.setupAiming()
		
		self.setupMouseLook()
		self.createFlashlight()
		
		"""
		The place for the held item. You'll probably want to replace this
		with a more sophisticated inventory system.
		"""
		self.heldItem = None
		
		"""
		Set one of two main variants of handling object carrying.
		See placeObjectInFrontOfCamera method to see what this is for.
		"""
		self.jiggleHeld = True
Ejemplo n.º 2
0
	def __init__(self, game, charNP=None):
		kinematicCharacterController.__init__(self, game, charNP)
		
		"""
		Additional Direct Object that I use for convenience.
		"""
		self.specialDirectObject = DirectObject()
		
		self.name = "Player"
		
		"""
		The flashlight
		"""
		self.flashlight = Spotlight("self.flashlight")
		self.flashlight.setColor(Vec4(1.0, 1.0, 1.0, 1.0))
		lens = PerspectiveLens()
		lens.setFov(100.0)
		self.flashlight.setLens(lens)
		self.flashlightNP = base.cam.attachNewNode(self.flashlight)
		self.flashlightState = False
		
		"""
		The place for the held item. You'll probably want to replace this
		with a more sophisticated inventory system.
		"""
		self.heldItem = None
		
		"""
		Set one of two main variants of handling object carrying.
		See placeObjectInFrontOfCamera method to see what this is for.
		"""
		self.jiggleHeld = True
		
		"""
		How high above the center of the capsule you want the camera to be
		when walking and when crouching. It's related to the values in KCC.
		"""
		self.walkCamH = 0.7
		self.crouchCamH = 0.2
		self.camH = self.walkCamH
		
		"""
		The variables below are related to mouselook.
		"""
		self.mouseLookSpeedX = 8.0
		self.mouseLookSpeedY = 1.2
		
		self.mousePrevX = 0.0
		self.mousePrevY = 0.0
		
		self.hCounter = 0
		self.h = 0.0
		self.p = 0.0
		self.pCounter = 0
		
		"""
		This tells the Player Controller what we're aiming at.
		"""
		self.aimed = None
		
		self.isSitting = False
		self.isDisabled = False
		
		"""
		The special direct object is used for trigger messages and the like.
		"""
		self.specialDirectObject.accept("ladder_trigger_enter", self.setFly, [True])
		self.specialDirectObject.accept("ladder_trigger_exit", self.setFly, [False])