diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide index ff76b55..5d2d0f2 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1fb1ba69420bf701266a582fef590a853b372d4d22a1e31ba047caec54371a0b +oid sha256:d608934d107d8fb52e3979ec301995b2514874c7355b03d7403dc07d6b1de5bd size 1028096 diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm index 18e2c1a..5df4b81 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:353baed719f408b743f68e68adde7c2a391e680fe9b6bba231924b5b5d144a10 +oid sha256:c5b87e0aea8f57f9afcffeeea959d9d5b13096fae5391f81a94f7e9694bb8aaa size 32768 diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal index 0e092b0..dcc869e 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e7d85fc1cd7e52ae5c3c70261ea42d55729b28400d99b590cb0b578189c04ea3 +oid sha256:f0c126c2227bb98418c09496e3947d76db4257919f65046cedba9b2e1b8e9716 size 4140632 diff --git a/2018-unity-sim/Assets/Main.unity b/2018-unity-sim/Assets/Main.unity index b30442b..46bcf37 100644 --- a/2018-unity-sim/Assets/Main.unity +++ b/2018-unity-sim/Assets/Main.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:747794c65fedc51eaf1915d291c3e149b26158aa02c9491f0c1dca1c3c7a2c90 -size 9969205 +oid sha256:cccf856e8bc96b9a519d22d7f282f3b9c28a8c17a6ee9109118d5071805e88d0 +size 9969207 diff --git a/2018-unity-sim/Assets/Walk.cs b/2018-unity-sim/Assets/Walk.cs index 44d3dc8..8b03700 100644 --- a/2018-unity-sim/Assets/Walk.cs +++ b/2018-unity-sim/Assets/Walk.cs @@ -13,6 +13,7 @@ public class Walk : MonoBehaviour for (int index = 0; index < legs.Count; ++index) { legsInitial.Add(legs[index].GetComponent().point); + step2.Add( new Vector3() ); } } @@ -61,6 +62,8 @@ public class Walk : MonoBehaviour public float walkspeed = 1; + private List step2 = new List(); + // Update is called once per frame void FixedUpdate() { @@ -85,17 +88,32 @@ public class Walk : MonoBehaviour t2.x *= walkspeed; // rotate x,y around rotation. - legs[index].GetComponent().point += Quaternion.Euler(0, rotation, 0) * t2; + step2[index] = (Quaternion.Euler(0, rotation, 0) * t2) / speed2; } else { - legs[index].GetComponent().point = legsInitial[index] + s[t].pos; + Vector3 t2 = s[t].pos; + t2.x *= walkspeed; + + // rotate x,y around rotation. + step2[index] = (Quaternion.Euler(0, rotation, 0) * t2) / speed2; } } speed = speed2; } else + { speed--; + makestep(); + } + } + + void makestep() + { + for (int index = 0; index < legs.Count; ++index) + { + legs[index].GetComponent().point += step2[index]; + } } } diff --git a/2018-unity-sim/Assets/Walk2.cs b/2018-unity-sim/Assets/Walk2.cs index d275907..548a1ec 100644 --- a/2018-unity-sim/Assets/Walk2.cs +++ b/2018-unity-sim/Assets/Walk2.cs @@ -13,6 +13,8 @@ public class Walk2 : MonoBehaviour for (int index = 0; index < legs.Count; ++index) { legsInitial.Add(legs[index].GetComponent().point); + step2.Add(0); + step3.Add(0); } } @@ -62,13 +64,15 @@ public class Walk2 : MonoBehaviour int size = 8; //public float walkspeed = 1; + private List step2 = new List(); + private List step3 = new List(); // Update is called once per frame void FixedUpdate() { if (speed <= 0) { - if (st >= size-1) + if (st >= size - 1) st = 0; else st++; @@ -83,21 +87,34 @@ public class Walk2 : MonoBehaviour if (s[t].inAir == false) { - Vector3 n = legs[index].GetComponent().getWorldPos(); - n = Quaternion.Euler(0, rotation * s[t].rotation, 0) * n; - n.y += s[t].height; - // rotate x,y around rotation. - legs[index].GetComponent().setWorldPos(n); + step2[index] = (rotation * s[t].rotation) / speed2; + step3[index] = s[t].height / speed2; } else { - legs[index].GetComponent().point = legsInitial[index] + new Vector3(0, s[t].height, 0); + step2[index] = (rotation * s[t].rotation) / speed2; + step3[index] = s[t].height / speed2; } } speed = speed2; } else + { speed--; + makestep(); + } + } + + void makestep() + { + for (int index = 0; index < legs.Count; ++index) + { + Vector3 n = legs[index].GetComponent().getWorldPos(); + n = Quaternion.Euler(0, step2[index], 0) * n; + n.y += step3[index]; + // rotate x,y around rotation. + legs[index].GetComponent().setWorldPos(n); + } } }