This commit is contained in:
Anuken
2021-08-04 13:52:17 -04:00
parent cfa844f960
commit 3be5296572
4 changed files with 19 additions and 6 deletions

View File

@@ -102,7 +102,7 @@ public class LogicAI extends AIController{
} }
//look where moving if there's nothing to aim at //look where moving if there's nothing to aim at
if(!shoot){ if(!shoot || !unit.type.omniMovement){
unit.lookAt(unit.prefRotation()); unit.lookAt(unit.prefRotation());
}else if(unit.hasWeapons() && unit.mounts.length > 0 && !unit.mounts[0].weapon.ignoreRotation){ //if there is, look at the object }else if(unit.hasWeapons() && unit.mounts.length > 0 && !unit.mounts[0].weapon.ignoreRotation){ //if there is, look at the object
unit.lookAt(unit.mounts[0].aimX, unit.mounts[0].aimY); unit.lookAt(unit.mounts[0].aimX, unit.mounts[0].aimY);
@@ -131,7 +131,13 @@ public class LogicAI extends AIController{
//do not move when infinite vectors are used. //do not move when infinite vectors are used.
if(vec.isNaN() || vec.isInfinite()) return; if(vec.isNaN() || vec.isInfinite()) return;
unit.approach(vec); if(unit.type.omniMovement){
unit.approach(vec);
}else{
unit.rotateMove(vec);
}
} }
@Override @Override

View File

@@ -59,6 +59,14 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
vel.approachDelta(vector, type.accel * realSpeed()); vel.approachDelta(vector, type.accel * realSpeed());
} }
public void rotateMove(Vec2 vec){
moveAt(Tmp.v2.trns(rotation, vec.len()));
if(!vec.isZero()){
rotation = Angles.moveToward(rotation, vec.angle(), type.rotateSpeed * Math.max(Time.delta, 1));
}
}
public void aimLook(Position pos){ public void aimLook(Position pos){
aim(pos); aim(pos);
lookAt(pos); lookAt(pos);

View File

@@ -645,6 +645,8 @@ public class DesktopInput extends InputHandler{
if(omni){ if(omni){
unit.moveAt(movement); unit.moveAt(movement);
}else{ }else{
unit.rotateMove(movement);
unit.moveAt(Tmp.v2.trns(unit.rotation, movement.len())); unit.moveAt(Tmp.v2.trns(unit.rotation, movement.len()));
//problem: actual unit rotation is controlled by velocity, but velocity is 1) unpredictable and 2) can be set to 0 //problem: actual unit rotation is controlled by velocity, but velocity is 1) unpredictable and 2) can be set to 0

View File

@@ -922,10 +922,7 @@ public class MobileInput extends InputHandler implements GestureListener{
if(omni){ if(omni){
unit.moveAt(movement); unit.moveAt(movement);
}else{ }else{
unit.moveAt(Tmp.v2.trns(unit.rotation, movement.len())); unit.rotateMove(movement);
if(!movement.isZero()){
unit.rotation = Angles.moveToward(unit.rotation, movement.angle(), unit.type.rotateSpeed * Math.max(Time.delta, 1));
}
} }
//update shooting if not building + not mining //update shooting if not building + not mining