研究出通过向量解算炮塔角度的方法
This commit is contained in:
parent
16807dda03
commit
0aee8d49cd
1 changed files with 19 additions and 0 deletions
|
@ -889,6 +889,25 @@ public abstract class VehicleEntity extends Entity {
|
|||
}
|
||||
}
|
||||
|
||||
public void autoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec, Vec3 targetVec) {
|
||||
float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(targetVec) + getYRotFromVector(shootVec));
|
||||
float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(targetVec) + getXRotFromVector(shootVec));
|
||||
|
||||
this.turretTurnSound(diffX, diffY, 0.95f);
|
||||
|
||||
if (entityData.get(TURRET_DAMAGED)) {
|
||||
ySpeed *= 0.2f;
|
||||
xSpeed *= 0.2f;
|
||||
}
|
||||
|
||||
float min = -ySpeed + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT);
|
||||
float max = ySpeed + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT);
|
||||
|
||||
this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.5f * diffX, -xSpeed, xSpeed), -maxXAngle, -minXAngle));
|
||||
this.setTurretYRot(this.getTurretYRot() - Mth.clamp(0.5f * diffY, min, max));
|
||||
turretYRotLock = Mth.clamp(0.9f * diffY, min, max);
|
||||
}
|
||||
|
||||
public void gunnerAngle(float ySpeed, float xSpeed) {
|
||||
Entity gunner = this.getNthEntity(1);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue