diff --git a/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm b/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm index 8c02b82..00d3b46 100644 Binary files a/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm and b/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal b/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal index 952fa77..8102398 100644 Binary files a/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal and b/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Assets/Main.unity b/Assets/Main.unity index fdf786d..0f71105 100644 --- a/Assets/Main.unity +++ b/Assets/Main.unity @@ -48740,7 +48740,7 @@ MonoBehaviour: m_EditorClassIdentifier: transformation: {x: 0, y: 2, z: 0} transformation2: {x: 0, y: 0, z: 0} - rotation: {x: -1, y: 0, z: 2, w: 0} + rotation: {x: 0, y: 0, z: 0, w: 0} rotation2: - {fileID: 636309705} - {fileID: 596626244} @@ -48756,7 +48756,7 @@ MonoBehaviour: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 311513960} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 62866dc69f17c5f40a7ec527e34e82f1, type: 3} m_Name: @@ -48769,7 +48769,7 @@ MonoBehaviour: - {fileID: 1772413224} - {fileID: 210611261} st: 5 - speed2: 30 + speed2: 1 rotation: 0 walkspeed: 1.5 --- !u!114 &311513964 @@ -48791,7 +48791,7 @@ MonoBehaviour: - {fileID: 1772413224} - {fileID: 210611261} st: 5 - speed2: 20 + speed2: 1 rotation: 5 --- !u!1 &311874317 GameObject: diff --git a/Assets/Serial.cs b/Assets/Serial.cs index d082e17..39e31ba 100644 --- a/Assets/Serial.cs +++ b/Assets/Serial.cs @@ -29,47 +29,37 @@ public class Serial { public void send(int start, int a, int b, int c) { + if (serialPort == null) + { + serialPort = new SerialPort(@"\\.\" + "COM10", 115200); + + try + { + serialPort.Open(); + serialPort.DiscardOutBuffer(); + serialPort.DiscardInBuffer(); + + enabled = true; + } + catch + { + enabled = false; + } + } + if (enabled) { - if (serialPort == null) - { - serialPort = new SerialPort(@"\\.\" + "COM10", 115200); - - try - { - serialPort.Open(); - serialPort.DiscardOutBuffer(); - serialPort.DiscardInBuffer(); - } - catch - { - enabled = false; - } - } - if (serialPort is SerialPort) { - - serialPort.Write(" #"); - serialPort.Write(start.ToString()); - serialPort.Write(" P"); - serialPort.Write(a.ToString()); - + string send = " #" + start.ToString() + " P" + a.ToString(); start++; - - serialPort.Write(" #"); - serialPort.Write(start.ToString()); - serialPort.Write(" P"); - serialPort.Write(b.ToString()); - + send = send + " #" + start.ToString() + " P" + b.ToString(); start++; + send = send + " #" + start.ToString() + " P" + c.ToString(); - serialPort.Write(" #"); - serialPort.Write(start.ToString()); - serialPort.Write(" P"); - serialPort.Write(c.ToString()); + send = send + " \r"; - serialPort.Write(" \r"); + serialPort.Write(send); } } } diff --git a/Assets/Walk.cs b/Assets/Walk.cs index 8b03700..4ecba33 100644 --- a/Assets/Walk.cs +++ b/Assets/Walk.cs @@ -92,11 +92,8 @@ public class Walk : MonoBehaviour } else { - Vector3 t2 = s[t].pos; - t2.x *= walkspeed; - - // rotate x,y around rotation. - step2[index] = (Quaternion.Euler(0, rotation, 0) * t2) / speed2; + Vector3 t2 = (legsInitial[index] + s[t].pos) - legs[index].GetComponent().point; + step2[index] = t2 / speed2; } } diff --git a/Assets/Walk2.cs b/Assets/Walk2.cs index 548a1ec..fbb7cc2 100644 --- a/Assets/Walk2.cs +++ b/Assets/Walk2.cs @@ -15,6 +15,7 @@ public class Walk2 : MonoBehaviour legsInitial.Add(legs[index].GetComponent().point); step2.Add(0); step3.Add(0); + step4.Add(new Vector3(0, 0, 0)); } } @@ -66,6 +67,7 @@ public class Walk2 : MonoBehaviour //public float walkspeed = 1; private List step2 = new List(); private List step3 = new List(); + private List step4 = new List(); // Update is called once per frame void FixedUpdate() @@ -89,11 +91,12 @@ public class Walk2 : MonoBehaviour { step2[index] = (rotation * s[t].rotation) / speed2; step3[index] = s[t].height / speed2; + step4[index] = new Vector3(0, 0, 0); } else { - step2[index] = (rotation * s[t].rotation) / speed2; - step3[index] = s[t].height / speed2; + Vector3 t2 = legsInitial[index] - legs[index].GetComponent().point; + step4[index] = t2 / speed2; } } @@ -110,11 +113,19 @@ public class Walk2 : MonoBehaviour { 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); + if (step4[index] == new Vector3(0, 0, 0)) + { + 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); + } + else + { + // return to home + legs[index].GetComponent().point += step4[index]; + } } } }