v9 walk3 wip

This commit is contained in:
2018-11-19 22:21:47 +01:00
parent 471f15c112
commit aa1f537137
6 changed files with 181 additions and 30 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5
View File
@@ -99,6 +99,11 @@ public class Leg : MonoBehaviour {
pointShouldBe.transform.localPosition = foot.pos;
}
public Vector3 getLocalPos()
{
return point;
}
public Vector3 getWorldPos()
{
return point + new Vector3((float)translateX, (float)translateY, (float)translateZ);
+97 -10
View File
@@ -14090,7 +14090,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &94996748
Transform:
m_ObjectHideFlags: 0
@@ -14104,7 +14104,7 @@ Transform:
- {fileID: 379804153}
- {fileID: 1946365704}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &95074500
GameObject:
@@ -48726,7 +48726,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &311513962
MonoBehaviour:
@@ -48816,7 +48816,7 @@ MonoBehaviour:
speed2: 10
walkDirection: 0
centerRotation: 0
walkspeed: 0
walkspeed: 2
--- !u!1 &311874317
GameObject:
m_ObjectHideFlags: 0
@@ -228287,6 +228287,92 @@ MeshFilter:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1412133529}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1412927092
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1412927096}
- component: {fileID: 1412927095}
- component: {fileID: 1412927094}
- component: {fileID: 1412927093}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &1412927093
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1412927092}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &1412927094
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1412927092}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &1412927095
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1412927092}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1412927096
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1412927092}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -17, z: 0}
m_LocalScale: {x: 100, y: 1, z: 100}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1414444048
GameObject:
m_ObjectHideFlags: 0
@@ -264078,11 +264164,11 @@ Transform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1640079160}
m_LocalRotation: {x: 0.17348617, y: -0.7424655, z: 0.21076319, w: 0.61174047}
m_LocalPosition: {x: 18.06, y: 16.81, z: 9.77}
m_LocalRotation: {x: 0.17348619, y: -0.7424655, z: 0.2107632, w: 0.61174047}
m_LocalPosition: {x: 29.37, y: 19.01, z: 9.77}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_Father: {fileID: 2129559091}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 31.683, y: -101.023, z: 0.017}
--- !u!1 &1640739921
@@ -299401,7 +299487,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1867828751
GameObject:
@@ -316302,7 +316388,7 @@ Transform:
- {fileID: 1051547784}
- {fileID: 1245260121}
m_Father: {fileID: 2129559091}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1971697617
GameObject:
@@ -339101,9 +339187,10 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1640079164}
- {fileID: 1971572978}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2130020849
GameObject:
+79 -20
View File
@@ -18,6 +18,9 @@ public class Walk3 : MonoBehaviour
//step3.Add(0);
//step4.Add(new Vector3(0, 0, 0));
step5.Add(new Vector3());
freeze.Add(false);
freeze_y.Add(false);
}
}
@@ -27,13 +30,15 @@ public class Walk3 : MonoBehaviour
public float rotation;
public float height;
public bool inAir;
public bool inRest;
public step(Vector3 p, float r, float h, bool i)
public step(Vector3 p, float r, float h, bool i, bool ir)
{
pos = p;
rotation = r;
height = 0;
inAir = i;
inRest = ir;
}
}
@@ -45,19 +50,19 @@ public class Walk3 : MonoBehaviour
}
step[] s = {
new step(new Vector3(-1, 0, 0), -1, 0, false),
new step(new Vector3(-1, 0, 0), -1, 0, false, false),
new step(new Vector3(0, -2, 0), 0, -2, false),
new step(new Vector3(0, -2, 0), 0, 0, false, false),
new step(new Vector3(0, 0, 0), 0, 0, false), // rest
new step(new Vector3(0, 0, 0), 0, 0, false, false), // rest
new step(new Vector3(1, 0, 0), 1, 0, false),
new step(new Vector3(1, 0, 0), 1, 0, false),
new step(new Vector3(1, 0, 0), 1, 0, false, true), // down middle
new step(new Vector3(1, 0, 0), 1, 0, false, false),
new step(new Vector3(0, 0, 0), 0, 0, false), // rest
new step(new Vector3(0, 0, 0), 0, 0, false, false), // rest
new step(new Vector3(0, 2, 0), 0, 2, false),
new step(new Vector3(-1, 0, 0), -1, 0, true),
new step(new Vector3(0, 2, 0), 0, 0, false, false),
new step(new Vector3(-1, 0, 0), -1, 0, true, false),
};
public int st = 5;
@@ -77,16 +82,57 @@ public class Walk3 : MonoBehaviour
private List<Vector3> step5 = new List<Vector3>();
private List<bool> step6 = new List<bool>();
private List<bool> freeze = new List<bool>();
private List<bool> freeze_y = new List<bool>();
// Update is called once per frame
void FixedUpdate()
{
if (speed <= 0)
{
if (st >= size - 1)
if (st >= size-1)
st = 0;
else
{
st++;
if (centerRotation == 0 && walkspeed == 0)
{
for (int index = 0; index < legs.Count; index++)
{
int t = st;
if (index == 1 || index == 3 || index == 5)
{
t = offset(st, 4, size);
}
if (s[t].inRest)
{
Vector3 lp = legs[index].GetComponent<Leg>().getLocalPos();// + s[t].pos;
//lp.y -= 2;
if ((Mathf.Abs(lp.y - (legsInitial[index].y-2)) < 0.0001f)
&& (Mathf.Abs(lp.z - legsInitial[index].z) < 0.0001f)
&& (Mathf.Abs(lp.x - legsInitial[index].x) < 1.0001f))
{
freeze[index] = true;
freeze_y[index] = true;
}
}
/*else
{
freeze[index] = false;
}*/
}
}
else
{
for (int index = 0; index < legs.Count; index++)
{
freeze[index] = false;
}
}
}
for (int index = 0; index < legs.Count; ++index)
{
int t = st;
@@ -95,22 +141,35 @@ public class Walk3 : MonoBehaviour
t = offset(st, 4, size);
}
if (s[t].inAir == false)
if (!freeze[index])
{
step2[index] = (centerRotation * s[t].rotation) / speed2;
if (s[t].inAir == false)
{
step2[index] = (centerRotation * s[t].rotation) / speed2;
Vector3 t2 = s[t].pos;
t2.x *= walkspeed;
// rotate x,y around rotation.
step5[index] = (Quaternion.Euler(0, walkDirection, 0) * t2) / speed2;
Vector3 t2 = s[t].pos;
t2.x *= walkspeed;
// rotate x,y around rotation.
if (freeze_y[index])
{
t2.y = 0;
}
step5[index] = (Quaternion.Euler(0, walkDirection, 0) * t2) / speed2;
step6[index] = true;
step6[index] = true;
}
else
{
Vector3 t2 = (legsInitial[index] + s[t].pos) - legs[index].GetComponent<Leg>().point;
step5[index] = t2 / speed2;
step6[index] = false;
freeze_y[index] = false;
}
}
else
{
Vector3 t2 = (legsInitial[index] + s[t].pos) - legs[index].GetComponent<Leg>().point;
step5[index] = t2 / speed2;
step5[index] = new Vector3(0, 0, 0);
step6[index] = false;
}
}