Showing the changes to scripts/tutorials/entity_scripts (1 of 7 files). Show all
Unified · Split
| @@ -94,9 +94,9 @@ · 93 unmodified lines | ||
| 94 | 94 | }, |
| 95 | 95 | |
| 96 | 96 | shootBall: function(gunProperties) { |
| 97 | − var forwardVec = Quat.getForward(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0))); | |
| 98 | − forwardVec = Vec3.normalize(forwardVec); | |
| 99 | − forwardVec = Vec3.multiply(forwardVec, GUN_FORCE); | |
| 97 | + var forwardVector = Quat.getForward(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0))); | |
| 98 | + forwardVector = Vec3.normalize(forwardVector); | |
| 99 | + forwardVector = Vec3.multiply(forwardVector, GUN_FORCE); | |
| 100 | 100 | |
| 101 | 101 | var properties = { |
| 102 | 102 | name: 'Tutorial Ping Pong Ball', |
| @@ -111,7 +111,7 @@ · 8 unmodified lines | ||
| 111 | 111 | rotation: gunProperties.rotation, |
| 112 | 112 | position: this.getGunTipPosition(gunProperties), |
| 113 | 113 | gravity: PING_PONG_GUN_GRAVITY, |
| 114 | − velocity: forwardVec, | |
| 114 | + velocity: forwardVector, | |
| 115 | 115 | lifetime: 10 |
| 116 | 116 | }; |
| 117 | 117 | |
| @@ -131,12 +131,12 @@ · 13 unmodified lines | ||
| 131 | 131 | |
| 132 | 132 | getGunTipPosition: function(properties) { |
| 133 | 133 | //the tip of the gun is going to be in a different place than the center, so we move in space relative to the model to find that position |
| 134 | − var frontVector = Quat.getForward(properties.rotation); | |
| 135 | − var frontOffset = Vec3.multiply(frontVector, GUN_TIP_FWD_OFFSET); | |
| 134 | + var forwardVector = Quat.getForward(properties.rotation); | |
| 135 | + var forwardOffset = Vec3.multiply(forwardVector, GUN_TIP_FWD_OFFSET); | |
| 136 | 136 | var upVector = Quat.getUp(properties.rotation); |
| 137 | 137 | var upOffset = Vec3.multiply(upVector, GUN_TIP_UP_OFFSET); |
| 138 | 138 | |
| 139 | − var gunTipPosition = Vec3.sum(properties.position, frontOffset); | |
| 139 | + var gunTipPosition = Vec3.sum(properties.position, forwardOffset); | |
| 140 | 140 | gunTipPosition = Vec3.sum(gunTipPosition, upOffset); |
| 141 | 141 | |
| 142 | 142 | return gunTipPosition; |