mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:36:56 +02:00
Add tunneling handling to pitching.js
This commit is contained in:
parent
779cadd5bd
commit
e9a2e91374
1 changed files with 12 additions and 2 deletions
|
@ -270,6 +270,18 @@ Baseball.prototype = {
|
||||||
if (name == "Bat") {
|
if (name == "Bat") {
|
||||||
if (this.state == BASEBALL_STATE.PITCHING) {
|
if (this.state == BASEBALL_STATE.PITCHING) {
|
||||||
print("HIT");
|
print("HIT");
|
||||||
|
var yaw = Math.atan2(myVelocity.x, myVelocity.z) * 180 / Math.PI;
|
||||||
|
var foul = yaw > -135 && yaw < 135;
|
||||||
|
|
||||||
|
if (foul && myVelocity.z > 0) {
|
||||||
|
var xzDist = Math.sqrt(myVelocity.x * myVelocity.x + myVelocity.z * myVelocity.z);
|
||||||
|
var pitch = Math.atan2(myVelocity.y, xzDist) * 180 / Math.PI;
|
||||||
|
print("Pitch: ", pitch);
|
||||||
|
if (Math.abs(pitch) < 15) {
|
||||||
|
print("Reversing hit");
|
||||||
|
myVelocity.z *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update ball velocity
|
// Update ball velocity
|
||||||
Entities.editEntity(self.entityID, {
|
Entities.editEntity(self.entityID, {
|
||||||
|
@ -293,8 +305,6 @@ Baseball.prototype = {
|
||||||
volume: 1.0
|
volume: 1.0
|
||||||
});
|
});
|
||||||
}, 500);
|
}, 500);
|
||||||
var yaw = Math.atan2(myVelocity.x, myVelocity.z) * 180 / Math.PI;
|
|
||||||
var foul = yaw > -135 && yaw < 135;
|
|
||||||
if (foul) {
|
if (foul) {
|
||||||
print("FOUL ", yaw)
|
print("FOUL ", yaw)
|
||||||
this.state = BASEBALL_STATE.FOUL;
|
this.state = BASEBALL_STATE.FOUL;
|
||||||
|
|
Loading…
Reference in a new issue