Torque Game Engine DocumentationVersion 1.3.x |
The PlayerData datablock class enables us to easily specify many aspects of player character behavior. PlayerData includes all the fields of ShapeBaseData, and adds many more which are specifically related to players and characters in games.
We will look at each field in PlayerData. For the sake of space and clarity, fields defined in ShapeBaseData are omitted from the table below.
Table D.3. PlayerData Member Fields
| Field Name | Type | Default Value | Description |
|---|---|---|---|
| Rendering Data | |||
| renderFirstPerson | Boolean | True | Specifies whether the player shape should be rendered in first person |
| Special Effect Data | |||
| DecalData | DecalDataPtr | NULL | If specified, this field must point to another datablock object of type DecalData. Must adhere to the semantics associated with DecalData*, as defined in the engine. |
| decalOffset | float | 0.0 | The offset from the player's center by which the decal should be displayed; should correlate with the distance from player's center, to the player's right foot center. |
| footPuffEmitter | FootPuffEmitterDataPtr | NULL | If specified, this field must point to another datablock of type FootPuffEmitterData. Must adhere to the semantics associated with FootPuffEmitterData*, as defined in the engine. |
| footPuffNumParts | Integer | 15 | Number of dust particles to be generated for foot puffs. |
| footPuffRadius | Float | 0.25 | The radius of dust spread from foot steps. |
| dustEmitter | ParticleEmitterDataPtr | NULL | If specified, must point to a datablock of type ParticleEmitterData. Must adhere to the semantics associated with ParticleEmitterData*, as defined in the Torque Game Engine. The ParticleEmitterData datablock will be used to emit particles at footstep locations. |
| FootSoftSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for soft footsteps. |
| FootHardSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for hard footsteps. |
| FootMetalSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for footsteps on metal. |
| FootSnowSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for footsteps on snow. |
| FootShallowSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for footsteps in shallow water. |
| FootWadingSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for footsteps in wading water. |
| FootUnderwaterSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for footsteps underwater. |
| FootBubblesSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for bubbles produced by footsteps. |
| movingBubblesSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for bubbles moving through the water. |
| waterBreathSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for breathing underwater. |
| impactSoftSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for soft impacts. |
| impactHardSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for hard impacts. |
| impactMetalSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for impacts against metal. |
| impactSnowSound | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for impacts against snow. |
| impactWaterEasy | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for soft impacts against water. |
| impactWaterMedium | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for medium impacts against water. |
| impactWaterHard | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds for hard impacts against water. |
| exitingWater | AudioProfilePtr | NULL | If specified, must point to an object of type AudioProfile. Must adhere to the semantics associated with AudioProfile*, as defined in the Torque Game Engine. The AudioProfile will be used to produce sounds when emerging from water. |
| mediumSplashSoundVelocity | float | 2.0 | The minimum velocity at which the medium splash effect will be played when impacting water. |
| hardSplashSoundVelocity | float | 3.0 | The minimum velocity at which the hard splash effect will be played when impacting water. |
| exitSplashSoundVelocity | float | 2.0 | The minimum velocity at which the exit splash sound will be played when emerging from water. |
| Splash | SplashDataPtr | NULL | If specified, must point to a datablock of type SplashData. Must adhere to the semantics associated with SplashData*, as defined in the Torque Game Engine. |
| splashVelocity | float | 1.0 | The mimimum velocity a player needs in order to generate a splash effect. |
| splashAngle | float | 45 | The mimimum verticle angle at which a player must be travelling in order to generate a splash effect. |
| splashFreqMod | float | 300.0 | The simulated frequency modulation of a splash generated by this player. Multiplied along with player speed and time elapsed when determining splash emition rate. |
| splashVelEpsilon | float | 0.25 | The threshold speed at which we consider the player's movement to have stopped when updating splash effects. |
| bubbleEmitTime | float | 0.4 | The length of time to continue emitting bubbles. |
| splashEmitter | ParticleEmitterDataPtr (array) | NULL [NUM_SPLASH_EMITTERS] | Array of pointers to ParticleEmitterData datablocks which will be used to generate splash effect particles. If specified, each pointer must reference a datablock of type ParticleEmitterData and must adhere to the semantics associated with ParticleEmitterData*, as defined in the Torque Game Engine. |
| footstepSplashHeight | float | 0.1 | The maximum height at which to play the shallow footstep effect. |
| groundImpactMinSpeed | float | 10.0 | The minimum speed at which the player must impact the ground in order to generate ground impact effects. |
| groundImpactShakeFreq | Point3F | (10.0, 10.0, 10.0) | The frequency at which to shake the camera if the player is a control object, and a ground impact effect is triggered. |
| groundImpactShakeAmp | Point3F | (20.0, 20.0, 20.0) | The amplitude at which to begin shaking the camera if the player is a control object, when a ground impact effect is triggered. |
| groundImpactShakeDuration | Float | 1.0 | The duration to shake the camera if the player is a control object, and a ground impact effect is triggered. |
| groundImpactShakeFalloff | Float | 10.0 | The amplitude falloff over time for camera shake effects generated when the player is a control object, and a ground impact effect is triggered. |
| View Restrictions Data | |||
| minLookAngle | float | -1.4 | The lowest angle that the player can look, in radians. |
| maxLookAngle | float | 1.4 | The highest angle that the player can look, in radians. |
| maxFreelookAngle | float | 3.0 | The max left/right angle the player can look, when in free look mode, in radians. |
| Player Movement Physics Data | |||
| runForce | Float | 360.0 | The simulated physcial force of the player when running. Used in running acceleration and speed calculations. |
| maxForwardSpeed | Float | 10.0 | The maximum speed at which the player can run forward when not in water. |
| maxBackwardSpeed | Float | 10.0 | The maximum speed at which the player can run backward when not in water. |
| maxSideSpeed | Float | 10.0 | The maximum speed at which the player can run sideways when not in water. |
| maxUnderwaterForwardSpeed | Float | 10.0 | The maximum speed at which the player can run forward when in water. |
| maxUnderwaterBackwardSpeed | Float | 10.0 | The maximum speed at which the player can run backward when in water. |
| maxUnderwaterSideSpeed | Float | 10.0 | The maximum speed at which the player can run sideways when in water. |
| maxStepHeight | Float | 1.0 | Maximum height the player can step up. |
| runSurfaceAngle | Float | 80.0 | Maximum degree from vertical that the player can run, in degrees. |
| horizMaxSpeed | Float | 80.0 | Maximum horizontal speed the player can attain via any means. |
| horizResistSpeed | Float | 38.0 | Horizontal speed at which resistance will set in. |
| horizResistFactor | Float | 1.0 | Horizontal resistance against player once horizResistSpeed has been attained. |
| upMaxSpeed | Float | 80.0 | Maximum upward speed the player can attain via any means. |
| upResistSpeed | Float | 38.0 | Upward speed at which resistance will set in. |
| horizResistFactor | Float | 1.0 | Upward resistance against player once upResistSpeed has been attained. |
| minImpactSpeed | Float | 25.0 | Minimum speed at which player must be travelling for an impact effect to be triggered. |
| recoverDelay | Integer | 30.0 | Number of ticks required for the player to recover from an impact. |
| recoverRunForceScale | Float | 1.0 | Multiplier used to modify the player's running force while recovering from an impact. |
| minJumpSpeed | Float | 500.0 | Minimum player speed at which to begin scaling jump height. |
| maxJumpSpeed | Float | 1000.0 | Maximum speed at which a player can jump. The value provided will be forced larger than minJumpSpeed. |
| jumpSurfaceAngle | Float | 78.0 | Angle from vertical in degrees where the player can jump. |
| jumpDelay | Integer | 78.0 | Delay time between jumps, in ticks. |
| jumpForce | Float | 75.0 | Force exerted by the player jumping. |
| minJumpEnergy | Float | 0.0 | Minimum energy required to jump. NOTE: this field may be removed in the future. |
| jumpEnergyDrain | Float | 0.0 | Player's energy drained by jumping. NOTE: this field may be removed in the future. |
| minRunEnergy | Float | 0.0 | Minimum energy required to run. NOTE: this field may be removed in the future. |
| runEnergyDrain | Float | 0.0 | Player's energy drained by running. NOTE: this field may be removed in the future. |
| Bounding Box Data | |||
| boundingBox | Point3F | (1.0, 1.0, 2.3) | This field specifies the width, depth, and height of the player's bounding box |
| boxHeadPercentage | Float | 0.85 | The distance from the bottom of the player's bounding box, to the beginning of the area considered to bound the player's head. Measured as a raw percentage. Thus, by default, the top 15% of the bounding box is considered to bound the player's head. |
| boxTorsoPercentage | Float | 0.55 | Like boxHeadPercentage, but specifies where the torso area begins. |
| boxHeadLeftPercentage | Integer | 0 | In conjunction with boxHeadRightPercentage, used to determine whether the left, middle, or right side of the player's torso or legs was hit. Note: this functionality is difficult to properly change; it is recommended that default values be used |
| boxHeadRightPercentage | Integer | 1 | See boxHeadLeftPercentage description. |
| boxHeadFrontPercentage | Integer | 1 | In conjunction with boxHeadBackPercentage, used to determine whether the front, middle, or back side of the player's torso or legs was hit. Note: this functionality is difficult to proprely change; it is recommended taht default values be used. |
| boxHeadBackPercentage | Integer | 0 | See boxHeadFrontPercentage description. |
| pickupRadius | Float | 0.0 | Radius around player for items (on server). When testing the value, Torque will, by default, force the pickupRadius to be not less than the larger of boundingBox.x and boundingBox.y and no more than twice the same. (pickupRadius must be >= max(boundingBox.x, boundingBox.y) and <= 2*max(boundingBox.x, boundingBox.y)) |
| Animation Data | |||
| maxTimeScale | Float | 1.5 | The maximum time scale allowed for player action animations. |
There you have it. Again, implementing datablocks based on PlayerData is a simple process identical to that which we saw for GameBaseData. There is one important note, however:
PlayerData datablocks must be given a non-empty string for the shapeFile field. If no shapeFile value is given, Torque will, by default, produce an error and quit. When working with PlayerData datablocks, always provide a non-empty string for the shapeFile field, even if it's only a dummy string. If a dummy string or invalid file name is given for a PlayerData datablock's shapeFile field, Torque will continue to run, but no data whatsoever will be retrievable from the datablock.
The Torque Game Engine does not define any derivative datablocks of PlayerData. In the next section, we'll look at another derivative of ShapeBaseData, ItemData.