no IK
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
@@ -19,7 +17,7 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio
|
||||
|
||||
transient Leg[] legs = {};
|
||||
transient float totalLength;
|
||||
transient int lastGroup;
|
||||
transient float moveSpace;
|
||||
transient float baseRotation;
|
||||
|
||||
@Override
|
||||
@@ -49,32 +47,29 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio
|
||||
}
|
||||
|
||||
float moveSpeed = type.legSpeed;
|
||||
int div = Math.max(legs.length / 2, 2);
|
||||
float moveSpace = legLength / 1.6f / (div / 2f) * type.legMoveSpace;
|
||||
int div = Math.max(legs.length / type.legGroupSize, 2);
|
||||
moveSpace = legLength / 1.6f / (div / 2f) * type.legMoveSpace;
|
||||
|
||||
totalLength += Mathf.dst(deltaX(), deltaY());
|
||||
|
||||
|
||||
//float movespace = 360f / legs.length / 4f;
|
||||
float stepMult = 0.8f;
|
||||
float trns = legLength/2f*stepMult * 1.3f;//Mathf.dst(deltaX(), deltaY()) * 12.5f * div/1.5f * type.legTrns;
|
||||
|
||||
//trns = moveSpace * 0.7f;
|
||||
//trns = 0;
|
||||
float trns = vel().len() * 12.5f * div/1.5f * type.legTrns;
|
||||
trns = moveSpace * 0.85f * type.legTrns;
|
||||
|
||||
//rotation + offset vector
|
||||
Vec2 posOffset = Tmp.v4.trns(rot, trns);
|
||||
float approach = Mathf.dst(deltaX(), deltaY());
|
||||
Tmp.v4.trns(rot, trns);
|
||||
|
||||
for(int i = 0; i < legs.length; i++){
|
||||
Leg l = legs[i];
|
||||
float dstRot = legAngle(rot, i);
|
||||
float rot2 = Angles.moveToward(dstRot, rot + (Angles.angleDist(dstRot, rot) < 90f ? 180f : 0), type.legBend * 360f / legs.length / 4f);
|
||||
boolean side = i < legs.length/2;
|
||||
//float rot2 = Angles.moveToward(dstRot, rot + (Angles.angleDist(dstRot, rot) < 90f ? 180f : 0), movespace);
|
||||
Leg l = legs[i];
|
||||
|
||||
int stage = (int)((totalLength + i*type.legPairOffset) / moveSpace);
|
||||
float stageF = (totalLength + i*type.legPairOffset) / moveSpace;
|
||||
int stage = (int)stageF;
|
||||
int group = stage % div;
|
||||
boolean move = i % div == group;
|
||||
l.moving = move;
|
||||
l.stage = stageF % 1f;
|
||||
|
||||
if(l.group != group){
|
||||
|
||||
@@ -82,9 +77,9 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio
|
||||
if(!move && i % div == l.group){
|
||||
Floor floor = Vars.world.floorWorld(l.base.x, l.base.y);
|
||||
if(floor.isLiquid){
|
||||
floor.walkEffect.at(l.base.x, l.base.y, 0, floor.mapColor);
|
||||
floor.walkEffect.at(l.base.x, l.base.y, type.rippleScale, floor.mapColor);
|
||||
}else{
|
||||
Fx.unitLandSmall.at(l.base.x, l.base.y, 0.5f, floor.mapColor);
|
||||
Fx.unitLandSmall.at(l.base.x, l.base.y, type.rippleScale, floor.mapColor);
|
||||
}
|
||||
|
||||
//shake when legs contact ground
|
||||
@@ -97,27 +92,19 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio
|
||||
l.group = group;
|
||||
}
|
||||
|
||||
Vec2 offset = Tmp.v5.trns(dstRot, type.legBaseOffset).add(x, y);
|
||||
|
||||
//leg destination
|
||||
Vec2 footDest = Tmp.v1.trns(dstRot - Mathf.sign(i % 2 == 0) * 0, legLength*stepMult).add(offset).add(posOffset);
|
||||
//joint destination
|
||||
//Tmp.v2.trns(rot2, legLength / 2f + type.legBaseOffset).add(x, y).add(offset);
|
||||
|
||||
Tmp.v1.trns(dstRot - Mathf.sign(i % 2 == 0) * 0f, legLength + type.legBaseOffset).add(x, y).add(Tmp.v4);
|
||||
//join destination
|
||||
Tmp.v2.trns(rot2, legLength / 2f + type.legBaseOffset).add(x, y).add(Tmp.v4);
|
||||
|
||||
if(move){
|
||||
l.base.lerpDelta(footDest, moveSpeed);
|
||||
//l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f);
|
||||
float moveFract = stageF % 1f;
|
||||
|
||||
l.base.lerpDelta(Tmp.v1, moveFract);
|
||||
l.joint.lerpDelta(Tmp.v2, moveFract / 2f);
|
||||
}
|
||||
|
||||
Vec2 result = Tmp.v2;
|
||||
InverseKinematics.solve(legLength/2f, legLength/2f, Tmp.v6.set(l.base).sub(offset), side, result);
|
||||
result.add(offset);
|
||||
|
||||
// if()
|
||||
|
||||
//l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f);
|
||||
l.joint.set(result);
|
||||
l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,14 +113,4 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio
|
||||
return rotation + 360f / legs.length * index + (360f / legs.length / 2f);
|
||||
}
|
||||
|
||||
/*
|
||||
@Replace
|
||||
public boolean isGrounded(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Replace
|
||||
public boolean isFlying(){
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user