Fixed extremely glitchy player pickup
This commit is contained in:
@@ -175,7 +175,7 @@ public class NetServer extends Module{
|
||||
NetConnection connection = Net.getConnection(id);
|
||||
if(player == null || connection == null || packet.snapid < connection.lastRecievedClientSnapshot) return;
|
||||
|
||||
boolean verifyPosition = !player.isDead() && !debug && headless && !player.mech.flying;
|
||||
boolean verifyPosition = !player.isDead() && !debug && headless && !player.mech.flying && player.getCarrier() == null;
|
||||
|
||||
if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = TimeUtils.millis() - 16;
|
||||
|
||||
|
||||
@@ -306,11 +306,18 @@ public class Renderer extends RendererModule{
|
||||
}
|
||||
}
|
||||
|
||||
//TODO extremely hacky
|
||||
if(t instanceof Player && ((Player) t).getCarry() != null && ((Player) t).getCarry() instanceof Player && ((Player) ((Player) t).getCarry()).isLocal){
|
||||
((Player) t).x = ((Player) t).getCarry().getX();
|
||||
((Player) t).y = ((Player) t).getCarry().getY();
|
||||
}
|
||||
|
||||
drawer.accept(t);
|
||||
|
||||
t.setX(lastx);
|
||||
t.setY(lasty);
|
||||
|
||||
if(threads.doInterpolate() && threads.isEnabled()) {
|
||||
t.setX(lastx);
|
||||
t.setY(lasty);
|
||||
|
||||
if (t instanceof SolidTrait) {
|
||||
((SolidTrait) t).setRotation(lastrot);
|
||||
|
||||
@@ -30,10 +30,7 @@ import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.ThreadQueue;
|
||||
import io.anuke.ucore.util.Timer;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -451,6 +448,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
updateBuilding(this); //building happens even with non-locals
|
||||
status.update(this); //status effect updating also happens with non locals for effect purposes
|
||||
|
||||
if(getCarrier() != null){
|
||||
x = getCarrier().getX();
|
||||
y = getCarrier().getY();
|
||||
}
|
||||
|
||||
if(Net.server()){
|
||||
updateShooting(); //server simulates player shooting
|
||||
}
|
||||
@@ -532,11 +534,16 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
|
||||
movement.limit(speed);
|
||||
|
||||
velocity.add(movement);
|
||||
|
||||
float prex = x, prey = y;
|
||||
updateVelocityStatus(mech.drag, 10f);
|
||||
moved = distanceTo(prex, prey) > 0.01f;
|
||||
if(getCarrier() == null){
|
||||
velocity.add(movement);
|
||||
float prex = x, prey = y;
|
||||
updateVelocityStatus(mech.drag, 10f);
|
||||
moved = distanceTo(prex, prey) > 0.01f;
|
||||
}else{
|
||||
velocity.setZero();
|
||||
x = Mathf.lerpDelta(x, getCarrier().getX(), 0.1f);
|
||||
y = Mathf.lerpDelta(y, getCarrier().getY(), 0.1f);
|
||||
}
|
||||
|
||||
if(!isShooting()){
|
||||
if(!movement.isZero()) {
|
||||
|
||||
@@ -196,7 +196,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
public void avoidOthers(float avoidRange){
|
||||
|
||||
EntityPhysics.getNearby(getGroup(), x, y, avoidRange*2f, t -> {
|
||||
if(t == this || (t instanceof Unit && (((Unit) t).isDead() || (((Unit) t).isFlying() != isFlying())))) return;
|
||||
if(t == this || (t instanceof Unit && (((Unit) t).isDead() || (((Unit) t).isFlying() != isFlying()) || ((Unit) t).getCarrier() == this) || getCarrier() == t)) return;
|
||||
float dst = distanceTo(t);
|
||||
if(dst > avoidRange) return;
|
||||
velocity.add(moveVector.set(x, y).sub(t.getX(), t.getY()).setLength(1f * (1f - (dst / avoidRange))));
|
||||
|
||||
Reference in New Issue
Block a user