diff --git a/.vs/Hexapod/v15/Server/sqlite3/storage.ide b/.vs/Hexapod/v15/Server/sqlite3/storage.ide index 1c24841..4b83fc5 100644 Binary files a/.vs/Hexapod/v15/Server/sqlite3/storage.ide and b/.vs/Hexapod/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm b/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm index 7285e7b..af954f4 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 d12ab00..a0c1bd4 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/Foot.cs b/Assets/Foot.cs index 6e38fb8..b53a6bb 100644 --- a/Assets/Foot.cs +++ b/Assets/Foot.cs @@ -1,6 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; using UnityEngine; public class Foot : Component @@ -19,7 +17,9 @@ public class Foot : Component // Inverse Kinemetics Region double l3, s; - double l1=10, l2=15; + public double l1=10; // top leg length + public double l2=15; // bottom leg length + static float knie_offset = 5.5f; // distancce from horziontal servo to knee servo. public double X, Y, Z; public double rotationX=0, rotationY=0, rotationZ=0; @@ -28,8 +28,6 @@ public class Foot : Component public Vector3 transformation = new Vector3(0, 0, 0); public Vector3 transformation2 = new Vector3(0, 0, 0); - static float knie_offset = 5.5f; - void RL3() { if ((X == 0) && (Z == 0)) diff --git a/Assets/JoyStick.meta b/Assets/JoyStick.meta new file mode 100644 index 0000000..9c4a1a1 --- /dev/null +++ b/Assets/JoyStick.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5f676c461da1c254990d7719d77e6250 +folderAsset: yes +timeCreated: 1641405303 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JoyStick/HandleHoystick.cs b/Assets/JoyStick/HandleHoystick.cs new file mode 100644 index 0000000..c2c914b --- /dev/null +++ b/Assets/JoyStick/HandleHoystick.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace Assets.JoyStick +{ + class HandleHoystick : MonoBehaviour + { + public RotationControl bot; + public Walk walk; + + public void Update() + { + float a2 = Remap(Input.GetAxis("1"), 1, -127, -1, 127); + float a1 = Remap(Input.GetAxis("2"), 1, -127, -1, 127); + float a3 = Remap(Input.GetAxis("3"), -1, -127, 1, 127); + + float b2 = Remap(Input.GetAxis("4"), -1, -127, 1, 127); + float b3 = Remap(Input.GetAxis("5"), -1, -127, 1, 127); + float b1 = Remap(Input.GetAxis("6"), -1, -127, 1, 127); + + //Debug.Log(Input.GetAxis("4")); + //Debug.Log(Remap(Input.GetAxis("4"), -1, -127, 1, 127)); + + bot.rotation = new Quaternion(limit(a2, -20, 20), -1 * limit(a3, -20, 20), -1 * limit(a1, -20, 20), + 1); + + float speed = (float)(Math.Sqrt(b1 * b1 + b2 * b2) / 127) * 3; + walk.walkspeed = speed < 0.5f ? 0 : speed; + + float rotation = -1 * limit(b3 / 4, -5, 5); + walk.centerRotation = rotation < 0.5f && rotation > -0.5f ? 0 : rotation; + + walk.walkDirection = (-1 * ConvertRadiansToDegrees((float)Math.Atan2(b2, b1))); + + float rotationabs = Math.Abs(walk.centerRotation); + float speed2 = ((6 / 3) * walk.walkspeed) + ((6 / 5) * rotationabs); + speed2 = speed2 < 6 ? speed2 : 6; + walk.speed2 = (int)(10 - speed2); + } + + public float limit(float input, float min, float max) + { + input = input / 6; + return (input < max & input > min) ? input : input < min ? min : max; + } + + public float ConvertRadiansToDegrees(float radians) + { + float degrees = (float)((180 / Math.PI) * radians); + return (degrees); + } + + public float Remap(float from, float fromMin, float toMin, float fromMax, float toMax) + { + var fromAbs = from - fromMin; + var fromMaxAbs = fromMax - fromMin; + + var normal = fromAbs / fromMaxAbs; + + var toMaxAbs = toMax - toMin; + var toAbs = toMaxAbs * normal; + + var to = toAbs + toMin; + + return to; + } + + } +} \ No newline at end of file diff --git a/Assets/Walk3.cs.meta b/Assets/JoyStick/HandleHoystick.cs.meta similarity index 77% rename from Assets/Walk3.cs.meta rename to Assets/JoyStick/HandleHoystick.cs.meta index 67297d2..cbe655b 100644 --- a/Assets/Walk3.cs.meta +++ b/Assets/JoyStick/HandleHoystick.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: a4266f2a53eea3a43972b07e077212bc -timeCreated: 1542307321 +guid: c5ce8a2605d301e44a4a210aa345ed62 +timeCreated: 1641405303 licenseType: Free MonoImporter: externalObjects: {} diff --git a/Assets/Leg.cs b/Assets/Leg.cs index a9095e3..43d791c 100644 --- a/Assets/Leg.cs +++ b/Assets/Leg.cs @@ -1,12 +1,11 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class Leg : MonoBehaviour { public Transform Hip1; public Transform Hip2; public Transform Knie; + // rotation angles for different servos public double a1 = 0; public double a2 = 0; public double a3 = 0; @@ -14,11 +13,12 @@ public class Leg : MonoBehaviour { public Vector3 point = new Vector3(10, 10, 0); public Quaternion rotation = new Quaternion(0, 0, 0, 0); - public Vector3 transformation = new Vector3(0, 0, 0); - public Vector3 transformation2 = new Vector3(0, 0, 0); + public Vector3 transformationBeforeRotation = new Vector3(0, 0, 0); + public Vector3 transformationAfterRotation = new Vector3(0, 0, 0); - public bool invert = false; + public bool invertForLeftLeg = false; + // translation to change origin to middle of body public double translateX = 0; public double translateY = 0; public double translateZ = 0; @@ -51,16 +51,16 @@ public class Leg : MonoBehaviour { foot.translateZ = translateZ; // transform before rotation. - foot.transformation = transformation; + foot.transformation = transformationBeforeRotation; // transform after rotation. - foot.transformation2 = transformation2; + foot.transformation2 = transformationAfterRotation; - foot.invert = invert; + foot.invert = invertForLeftLeg; foot.setleg(); - if (!invert) + if (!invertForLeftLeg) { a1 = foot.O1 - 90; a2 = 90 - foot.O2; @@ -73,23 +73,33 @@ public class Leg : MonoBehaviour { a3 = foot.O3 - 90; } - if (!invert && startServo != -1) + if (!invertForLeftLeg && startServo != -1) { + // Serial.Instance.send(startServo, + // (int)Remap((float)a1, -90, 90, 2500, 500), + // (int)Remap((float)a2, -90, 90, 2500, 500), // 0 is middel + // (int)Remap((float)a3, 90, -90, 2500, 500)); // 0 is middel + if(false) Serial.Instance.send(startServo, - (int)Remap((float)a1, -90, 90, 2500, 500), - (int)Remap((float)a2, -90, 90, 2500, 500), // 0 is middel - (int)Remap((float)a3, 90, -90, 2500, 500)); // 0 is middel + (int)Remap((float)a1, -90, 90, 0, 180), + (int)Remap((float)a2, 90, -90, 0, 180), // 0 is middel + (int)Remap((float)a3, -90, 90, 0, 180)); // 0 is middel } - else if (invert && startServo != -1) + else if (invertForLeftLeg && startServo != -1) { double a1 = foot.O1 - 90; double a2 = 90 - foot.O2; double a3 = foot.O3 - 90; - Serial.Instance.send(startServo, - (int)Remap((float)a1, -90, 90, 500, 2500), - (int)Remap((float)a2, -90, 90, 500, 2500), // 0 is middel - (int)Remap((float)a3, 90, -90, 500, 2500)); // 0 is middel + // Serial.Instance.send(startServo, + // (int)Remap((float)a1, -90, 90, 500, 2500), + // (int)Remap((float)a2, -90, 90, 500, 2500), // 0 is middel + // (int)Remap((float)a3, 90, -90, 500, 2500)); // 0 is middel + if (false) + Serial.Instance.send(startServo, + (int)Remap((float)a1, 90, -90, 0, 180), + (int)Remap((float)a2, -90, 90, 0, 180), // 0 is middel + (int)Remap((float)a3, 90, -90, 0, 180)); // 0 is middel } Hip1.transform.localRotation = Quaternion.Euler(0, (float)a1, 0); diff --git a/Assets/Main.unity b/Assets/Main.unity index d6fac74..a39c1fb 100644 --- a/Assets/Main.unity +++ b/Assets/Main.unity @@ -10529,7 +10529,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &73925799 Transform: m_ObjectHideFlags: 0 @@ -10541,7 +10541,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &73925800 MonoBehaviour: @@ -10549,7 +10549,7 @@ MonoBehaviour: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 73925798} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 7fa025fa8dcb3a249b67fc0e2fe67b44, type: 3} m_Name: @@ -10563,6 +10563,7 @@ MonoBehaviour: b2: 0 b3: 0 enabled: 0 + enabled_send: 0 --- !u!1 &74230589 GameObject: m_ObjectHideFlags: 0 @@ -14153,7 +14154,7 @@ Transform: - {fileID: 379804153} - {fileID: 1946365704} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &95074500 GameObject: @@ -34470,14 +34471,14 @@ MonoBehaviour: a3: 0 point: {x: 5, y: -15, z: -13} rotation: {x: 0, y: 0, z: 0, w: 0} - transformation: {x: 0, y: 0, z: 0} - transformation2: {x: 0, y: 0, z: 0} - invert: 1 + transformationBeforeRotation: {x: 0, y: 0, z: 0} + transformationAfterRotation: {x: 0, y: 0, z: 0} + invertForLeftLeg: 1 translateX: 5 translateY: 0 translateZ: -5 pointShouldBe: {fileID: 32992308} - startServo: 22 + startServo: 9 --- !u!1 &211071650 GameObject: m_ObjectHideFlags: 0 @@ -48754,8 +48755,6 @@ GameObject: m_Component: - component: {fileID: 311513961} - component: {fileID: 311513962} - - component: {fileID: 311513963} - - component: {fileID: 311513964} - component: {fileID: 311513965} m_Layer: 0 m_Name: RotationControl @@ -48771,7 +48770,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 311513960} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 27.58, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -48800,49 +48799,6 @@ MonoBehaviour: - {fileID: 210611261} body: {fileID: 2129559090} body2: {fileID: 1971572977} ---- !u!114 &311513963 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 311513960} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 62866dc69f17c5f40a7ec527e34e82f1, type: 3} - m_Name: - m_EditorClassIdentifier: - legs: - - {fileID: 636309705} - - {fileID: 596626244} - - {fileID: 1619174560} - - {fileID: 1453644144} - - {fileID: 1772413224} - - {fileID: 210611261} - st: 5 - speed2: 1 - rotation: 0 - walkspeed: 1.5 ---- !u!114 &311513964 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 311513960} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 91e6f3895f276d94da1803128e6290e0, type: 3} - m_Name: - m_EditorClassIdentifier: - legs: - - {fileID: 636309705} - - {fileID: 596626244} - - {fileID: 1619174560} - - {fileID: 1453644144} - - {fileID: 1772413224} - - {fileID: 210611261} - st: 5 - speed2: 1 - rotation: 5 --- !u!114 &311513965 MonoBehaviour: m_ObjectHideFlags: 0 @@ -48865,7 +48821,7 @@ MonoBehaviour: speed2: 10 walkDirection: 0 centerRotation: 0 - walkspeed: 3 + walkspeed: 0 --- !u!1 &311874317 GameObject: m_ObjectHideFlags: 0 @@ -92991,9 +92947,9 @@ MonoBehaviour: a3: 0 point: {x: 0, y: -15, z: 13} rotation: {x: 0, y: 0, z: 0, w: 0} - transformation: {x: 0, y: 0, z: 0} - transformation2: {x: 0, y: 0, z: 0} - invert: 0 + transformationBeforeRotation: {x: 0, y: 0, z: 0} + transformationAfterRotation: {x: 0, y: 0, z: 0} + invertForLeftLeg: 0 translateX: 0 translateY: 0 translateZ: 6.5 @@ -99514,14 +99470,14 @@ MonoBehaviour: a3: 0 point: {x: -5, y: -15, z: 13} rotation: {x: 0, y: 0, z: 0, w: 0} - transformation: {x: 0, y: 0, z: 0} - transformation2: {x: 0, y: 0, z: 0} - invert: 0 + transformationBeforeRotation: {x: 0, y: 0, z: 0} + transformationAfterRotation: {x: 0, y: 0, z: 0} + invertForLeftLeg: 0 translateX: -5 translateY: 0 translateZ: 5 pointShouldBe: {fileID: 2018746516} - startServo: 0 + startServo: 6 --- !u!1 &636734778 GameObject: m_ObjectHideFlags: 0 @@ -228420,7 +228376,7 @@ Transform: m_LocalScale: {x: 100, y: 1, z: 100} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1414444048 GameObject: @@ -234926,14 +234882,14 @@ MonoBehaviour: a3: 0 point: {x: -5, y: -15, z: -13} rotation: {x: 0, y: 0, z: 0, w: 0} - transformation: {x: 0, y: 0, z: 0} - transformation2: {x: 0, y: 0, z: 0} - invert: 1 + transformationBeforeRotation: {x: 0, y: 0, z: 0} + transformationAfterRotation: {x: 0, y: 0, z: 0} + invertForLeftLeg: 1 translateX: -5 translateY: 0 translateZ: -5 pointShouldBe: {fileID: 591879371} - startServo: 16 + startServo: 15 --- !u!1 &1454125721 GameObject: m_ObjectHideFlags: 0 @@ -259448,14 +259404,14 @@ MonoBehaviour: a3: 0 point: {x: 5, y: -15, z: 13} rotation: {x: 0, y: 0, z: 0, w: 0} - transformation: {x: 0, y: 0, z: 0} - transformation2: {x: 0, y: 0, z: 0} - invert: 0 + transformationBeforeRotation: {x: 0, y: 0, z: 0} + transformationAfterRotation: {x: 0, y: 0, z: 0} + invertForLeftLeg: 0 translateX: 5 translateY: 0 translateZ: 5 pointShouldBe: {fileID: 1943602706} - startServo: 6 + startServo: 0 --- !u!1 &1619291355 GameObject: m_ObjectHideFlags: 0 @@ -265153,6 +265109,48 @@ Transform: m_Father: {fileID: 1921902568} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1645933597 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1645933599} + - component: {fileID: 1645933598} + m_Layer: 0 + m_Name: Input + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1645933598 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1645933597} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c5ce8a2605d301e44a4a210aa345ed62, type: 3} + m_Name: + m_EditorClassIdentifier: + bot: {fileID: 311513962} + walk: {fileID: 311513965} +--- !u!4 &1645933599 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1645933597} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -36.648933, y: -31.721676, z: -22.529099} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1646259228 GameObject: m_ObjectHideFlags: 0 @@ -284148,14 +284146,14 @@ MonoBehaviour: a3: 0 point: {x: 0, y: -15, z: -13} rotation: {x: 0, y: 0, z: 0, w: 0} - transformation: {x: 0, y: 0, z: 0} - transformation2: {x: 0, y: 0, z: 0} - invert: 1 + transformationBeforeRotation: {x: 0, y: 0, z: 0} + transformationAfterRotation: {x: 0, y: 0, z: 0} + invertForLeftLeg: 1 translateX: 0 translateY: 0 translateZ: -6.5 pointShouldBe: {fileID: 955360344} - startServo: 19 + startServo: 12 --- !u!1 &1772635191 GameObject: m_ObjectHideFlags: 0 @@ -299532,7 +299530,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1867357888} m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalPosition: {x: 45.12, y: 56.06, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -339239,7 +339237,7 @@ Transform: - {fileID: 1640079164} - {fileID: 1971572978} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2130020849 GameObject: diff --git a/Assets/RotationControl.cs b/Assets/RotationControl.cs index 8d837fc..5f443a4 100644 --- a/Assets/RotationControl.cs +++ b/Assets/RotationControl.cs @@ -81,13 +81,13 @@ public class RotationControl : MonoBehaviour //rotation.y = r2.update(); //rotation.z = r3.update(); - //transformation.x = r4.update(); - //transformation.y = r5.update(); - //transformation.z = r6.update(); + //transformationBeforeRotation.x = r4.update(); + //transformationBeforeRotation.y = r5.update(); + //transformationBeforeRotation.z = r6.update(); - /*transformation2.x = r7.update(); - transformation2.y = r8.update(); - transformation2.z = r9.update();*/ + /*transformationAfterRotation.x = r7.update(); + transformationAfterRotation.y = r8.update(); + transformationAfterRotation.z = r9.update();*/ body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y*-1, rotation.z*-1); body.transform.position = transformation; @@ -96,8 +96,8 @@ public class RotationControl : MonoBehaviour for (int index = 0; index < rotation2.Count; ++index) { rotation2[index].GetComponent().rotation = rotation; - rotation2[index].GetComponent().transformation = transformation; - rotation2[index].GetComponent().transformation2 = transformation2; + rotation2[index].GetComponent().transformationBeforeRotation = transformation; + rotation2[index].GetComponent().transformationAfterRotation = transformation2; rotation2[index].GetComponent().FixedUpdate(); } } diff --git a/Assets/Serial.cs b/Assets/Serial.cs deleted file mode 100644 index 39e31ba..0000000 --- a/Assets/Serial.cs +++ /dev/null @@ -1,67 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.IO.Ports; - -public class Serial { - private static Serial instance; - - private Serial() { } - - ~Serial() { - serialPort.Close(); - } - - public static Serial Instance - { - get - { - if (instance == null) - { - instance = new Serial(); - } - return instance; - } - } - - public bool enabled = false; - - SerialPort serialPort; - - 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 is SerialPort) - { - string send = " #" + start.ToString() + " P" + a.ToString(); - start++; - send = send + " #" + start.ToString() + " P" + b.ToString(); - start++; - send = send + " #" + start.ToString() + " P" + c.ToString(); - - send = send + " \r"; - - serialPort.Write(send); - } - } - } - -} diff --git a/Assets/Serial.meta b/Assets/Serial.meta new file mode 100644 index 0000000..87b3f4c --- /dev/null +++ b/Assets/Serial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 942facdab943ceb4ca29453f4ee4d1b3 +folderAsset: yes +timeCreated: 1641404792 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Serial/Serial.cs b/Assets/Serial/Serial.cs new file mode 100644 index 0000000..0c5a03d --- /dev/null +++ b/Assets/Serial/Serial.cs @@ -0,0 +1,119 @@ +using System; +using UnityEngine; +using System.Collections; +using System.IO.Ports; +using Random = System.Random; + +public class Serial +{ + private static Serial instance; + private int rnd = 0; + + private Serial() + { + } + + ~Serial() + { + serialPort.Close(); + serialPort.Dispose(); + } + + public static Serial Instance + { + get + { + if (instance == null) + { + instance = new Serial(); + } + + return instance; + } + } + + public bool enabled = false; + + public SerialPort serialPort; + + public int[] values = new int[18]; + + public static string ByteArrayToString(byte[] ba) + { + return BitConverter.ToString(ba).Replace("-", " "); + } + + public void send(int start, int a, int b, int c) + { + if (serialPort == null) + { + serialPort = new SerialPort(@"\\.\" + "COM4", 250000); + + try + { + serialPort.Parity = Parity.Even; + serialPort.StopBits = StopBits.One; + serialPort.DataBits = 8; + serialPort.Open(); + serialPort.DiscardOutBuffer(); + serialPort.DiscardInBuffer(); + System.Threading.Thread.Sleep(1000); + + enabled = true; + } + catch + { + enabled = false; + } + } + + if (enabled) + { + values[start] = a; + values[++start] = b; + values[++start] = c; + + if (serialPort is SerialPort && start == 17) + { + // string send = "s"; + byte[] send = new byte[18+1+2]; + send[18] = 0x00; + send[19] = 0xfe; + send[20] = 0xff; + // send[21] = 0xff; + + // if (rnd == 0) + // { + //rnd = 1; + for (int i = 0; i < 18; i++) + { + //string crc = ((i) * (values[i])) + ""; + //send = send + (i).ToString() + "_" + (values[i]).ToString() + "," + crc + "="; + byte[] intBytes = BitConverter.GetBytes(values[i]); + if (BitConverter.IsLittleEndian) + Array.Reverse(intBytes); + send[i] = intBytes[3]; + send[18] += send[i]; + } + + // Debug.Log(ByteArrayToString(send)); + serialPort.Write(send, 0, 18+1+2); + serialPort.BaseStream.Flush(); +// } +// else +// { +// rnd = 0; +// for (int i = 10; i < 18; i++) +// { +// string crc = ((i + 3) * (values[i])) + ""; +// +// send = send + (i + 2).ToString() + "_" + (values[i]).ToString() + "," + crc + "="; +// } +// +// Debug.Log(send); +// serialPort.Write(send); +// } + } + } + } +} diff --git a/Assets/Serial.cs.meta b/Assets/Serial/Serial.cs.meta similarity index 100% rename from Assets/Serial.cs.meta rename to Assets/Serial/Serial.cs.meta diff --git a/Assets/Serial2.cs b/Assets/Serial/Serial2.cs similarity index 98% rename from Assets/Serial2.cs rename to Assets/Serial/Serial2.cs index ffe7715..86cfa95 100644 --- a/Assets/Serial2.cs +++ b/Assets/Serial/Serial2.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using UnityEngine; using System.Collections; using System.IO.Ports; @@ -67,3 +67,4 @@ public class Serial2 : MonoBehaviour{ } } +*/ \ No newline at end of file diff --git a/Assets/Serial2.cs.meta b/Assets/Serial/Serial2.cs.meta similarity index 100% rename from Assets/Serial2.cs.meta rename to Assets/Serial/Serial2.cs.meta diff --git a/Assets/Serial/Serial3.cs b/Assets/Serial/Serial3.cs new file mode 100644 index 0000000..17dd6d9 --- /dev/null +++ b/Assets/Serial/Serial3.cs @@ -0,0 +1,170 @@ +//using System; +//using UnityEngine; +//using System.Collections; +//using System.IO.Ports; +//using System.Linq; +//using UnityEngine.UI; + +//public class Serial3 : MonoBehaviour{ + +// public RotationControl bot; +// public Walk walk; + +// public float a1, a2, a3, b1, b2, b3; + +// // ~Serial3() +// // { +// // serialPort.Close(); +// // serialPort.Dispose(); +// // } + +// public bool enabled = false; +// public bool enabled_send = false; + +// SerialPort serialPort; + +// public void Update() +// { +// if (serialPort == null) +// { +// serialPort = new SerialPort(@"\\.\" + "COM7", 230400); + +// try +// { +// serialPort.NewLine = "\r\n"; + +//// serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); + +// serialPort.Open(); +// serialPort.DiscardOutBuffer(); +// serialPort.DiscardInBuffer(); + +// enabled = true; +// } +// catch +// { +// enabled = false; +// } +// } + +// if (enabled) +// { +// serialPort = Serial.Instance.serialPort; +// Serial.Instance.enabled = enabled_send; +// if (serialPort is SerialPort) +// { +// string received = serialPort.ReadLine(); +// string[] data = received.Split(','); + +// foreach (string d in data) +// { + +// string[] ch = d.Split('_'); + +// int channel = int.Parse(ch.First()); +// float value = float.Parse(ch.Last()); + +// switch (channel) +// { +// case 0: +// a1 = value - 127; +// break; +// case 1: +// a2 = value - 127; +// break; +// case 2: +// a3 = value - 127; +// break; +// case 3: +// b1 = value - 127; +// break; +// case 4: +// b2 = value - 127; +// break; +// case 5: +// b3 = value - 127; +// break; +// } + +// bot.rotation = new Quaternion(limit(a2, -20, 20), -1 * limit(a3, -20, 20), -1 * limit(a1, -20, 20), +// 1); + +// float speed = (float) (Math.Sqrt(b1 * b1 + b2 * b2) / 127) * 3; +// walk.walkspeed = speed < 0.5f ? 0 : speed; + +// float rotation = -1 * limit(b3/4, -5, 5); +// walk.centerRotation = rotation < 0.5f && rotation > -0.5f ? 0 : rotation; + +// walk.walkDirection = (-1 * ConvertRadiansToDegrees((float) Math.Atan2(b2, b1))); + +// float rotationabs = Math.Abs(walk.centerRotation); +// float speed2 = ((6 / 3) * walk.walkspeed) + ((6/5) * rotationabs); +// speed2 = speed2 < 6 ? speed2 : 6; +// walk.speed2 = (int)(10 - speed2); +// } +// } +// } +// } + +// private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) +// { +// SerialPort serialPort = (SerialPort)sender; + +// if (enabled) +// { +// if (serialPort is SerialPort) +// { +// string received = serialPort.ReadLine(); +// string[] data = received.Split(','); + +// foreach (string d in data) +// { +// // if (data == "\r") +// // continue; + +// string[] ch = d.Split('_'); + +// int channel = int.Parse(ch.First()); +// float value = float.Parse(ch.Last()); + +// switch (channel) +// { +// case 0: +// a1 = value; +// break; +// case 1: +// a2 = value; +// break; +// case 2: +// a3 = value; +// break; +// case 3: +// b1 = value; +// break; +// case 4: +// b2 = value; +// break; +// case 5: +// b3 = value; +// break; +// } +// } + +// // bot.rotation = new Quaternion(-1* limit(y, -30, 30), 0, -1* limit(x, -30, 30), 1); +// } +// } +// } + +// public float limit(float input, float min, float max) +// { +// input = input / 6; +// return (input < max & input > min) ? input : input < min ? min : max; +// } + +// public float ConvertRadiansToDegrees(float radians) +// { +// float degrees = (float)((180 / Math.PI) * radians); +// return (degrees); +// } + +//} diff --git a/Assets/Serial3.cs.meta b/Assets/Serial/Serial3.cs.meta similarity index 100% rename from Assets/Serial3.cs.meta rename to Assets/Serial/Serial3.cs.meta diff --git a/Assets/Serial3.cs b/Assets/Serial3.cs deleted file mode 100644 index 5277af8..0000000 --- a/Assets/Serial3.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using UnityEngine; -using System.Collections; -using System.IO.Ports; -using System.Linq; -using UnityEngine.UI; - -public class Serial3 : MonoBehaviour{ - - public RotationControl bot; - public Walk3 walk; - - public float a1, a2, a3, b1, b2, b3; - - ~Serial3() { - serialPort.Close(); - } - - public bool enabled = false; - - SerialPort serialPort; - - public void Update() - { - if (serialPort == null) - { - serialPort = new SerialPort(@"\\.\" + "COM7", 115200); - - try - { - serialPort.NewLine = "\r\n"; - -// serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); - - serialPort.Open(); - serialPort.DiscardOutBuffer(); - serialPort.DiscardInBuffer(); - - enabled = true; - } - catch - { - enabled = false; - } - } - - if (enabled) - { - if (serialPort is SerialPort) - { - string received = serialPort.ReadLine(); - string[] data = received.Split(','); - - foreach (string d in data) - { - - string[] ch = d.Split('_'); - - int channel = int.Parse(ch.First()); - float value = float.Parse(ch.Last()); - - switch (channel) - { - case 0: - a1 = value - 127; - break; - case 1: - a2 = value - 127; - break; - case 2: - a3 = value - 127; - break; - case 3: - b1 = value - 127; - break; - case 4: - b2 = value - 127; - break; - case 5: - b3 = value - 127; - break; - } - - bot.rotation = new Quaternion(limit(a2, -20, 20), -1 * limit(a3, -20, 20), -1 * limit(a1, -20, 20), - 1); - - float speed = (float) (Math.Sqrt(b1 * b1 + b2 * b2) / 127) * 3; - walk.walkspeed = speed < 0.5f ? 0 : speed; - - float rotation = -1 * limit(b3/4, -5, 5); - walk.centerRotation = rotation < 0.5f && rotation > -0.5f ? 0 : rotation; - - walk.walkDirection = (-1 * ConvertRadiansToDegrees((float) Math.Atan2(b2, b1))); - - float rotationabs = Math.Abs(walk.centerRotation); - float speed2 = ((6 / 3) * walk.walkspeed) + ((6/5) * rotationabs); - speed2 = speed2 < 6 ? speed2 : 6; - walk.speed2 = (int)(10 - speed2); - } - } - } - } - - private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) - { - SerialPort serialPort = (SerialPort)sender; - - if (enabled) - { - if (serialPort is SerialPort) - { - string received = serialPort.ReadLine(); - string[] data = received.Split(','); - - foreach (string d in data) - { - // if (data == "\r") - // continue; - - string[] ch = d.Split('_'); - - int channel = int.Parse(ch.First()); - float value = float.Parse(ch.Last()); - - switch (channel) - { - case 0: - a1 = value; - break; - case 1: - a2 = value; - break; - case 2: - a3 = value; - break; - case 3: - b1 = value; - break; - case 4: - b2 = value; - break; - case 5: - b3 = value; - break; - } - } - - // bot.rotation = new Quaternion(-1* limit(y, -30, 30), 0, -1* limit(x, -30, 30), 1); - } - } - } - - public float limit(float input, float min, float max) - { - input = input / 6; - return (input < max & input > min) ? input : input < min ? min : max; - } - - public float ConvertRadiansToDegrees(float radians) - { - float degrees = (float)((180 / Math.PI) * radians); - return (degrees); - } - -} diff --git a/Assets/Walk.cs b/Assets/Walk.cs index 4ecba33..346e383 100644 --- a/Assets/Walk.cs +++ b/Assets/Walk.cs @@ -13,19 +13,32 @@ public class Walk : MonoBehaviour for (int index = 0; index < legs.Count; ++index) { legsInitial.Add(legs[index].GetComponent().point); - step2.Add( new Vector3() ); + step2.Add(0); + step6.Add(false); + //step3.Add(0); + //step4.Add(new Vector3(0, 0, 0)); + step5.Add(new Vector3()); + + freeze.Add(false); + freeze_y.Add(false); } } struct step { public Vector3 pos; + public float rotation; + public float height; public bool inAir; + public bool inRest; - public step(Vector3 p, bool i) + public step(Vector3 p, float r, float h, bool i, bool ir) { pos = p; + rotation = r; + height = 0; inAir = i; + inRest = ir; } } @@ -37,63 +50,159 @@ public class Walk : MonoBehaviour } step[] s = { - new step(new Vector3(-1, 0, 0), false), + new step(new Vector3(-1, 0, 0), -1, 0, false, false), - new step(new Vector3(0, -2, 0), false), + new step(new Vector3(0, -2, 0), 0, 0, false, false), - new step(new Vector3(0, 0, 0), false), // rest + new step(new Vector3(0, 0, 0), 0, 0, false, false), // rest - new step(new Vector3(1, 0, 0), false), - new step(new Vector3(1, 0, 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), false), // rest + new step(new Vector3(0, 0, 0), 0, 0, false, false), // rest - new step(new Vector3(0, 2, 0), false), - new step(new Vector3(-1, 0, 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; public int speed2 = 30; int speed = 10; - public float rotation = 0; + public float walkDirection = 0; + public float centerRotation = 0; int size = 8; public float walkspeed = 1; - private List step2 = new List(); + private List step2 = new List(); + //private List step3 = new List(); + //private List step4 = new List(); + private List step5 = new List(); + private List step6 = new List(); + + private List freeze = new List(); + private List freeze_y = 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++; + 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().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; - if (index == 1 || index == 3 || index == 5) - { - t = offset(st, 4, size); - } - if (s[t].inAir == false) + if (true) { - Vector3 t2 = s[t].pos; - t2.x *= walkspeed; - - // rotate x,y around rotation. - step2[index] = (Quaternion.Euler(0, rotation, 0) * t2) / speed2; + // Hex walk + if (index == 1 || index == 3 || index == 5) + { + t = offset(st, 4, size); + } } else { - Vector3 t2 = (legsInitial[index] + s[t].pos) - legs[index].GetComponent().point; - step2[index] = t2 / speed2; + // One leg at a time walk + switch (index) + { + case 0: + t = offset(st, 0, size); + break; + case 1: + t = offset(st, 4, size); + break; + case 2: + t = offset(st, 2, size); + break; + case 3: + t = offset(st, 3, size); + break; + case 4: + t = offset(st, 1, size); + break; + case 5: + t = offset(st, 5, size); + break; + } + } + + if (!freeze[index]) + { + 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. + if (freeze_y[index]) + { + t2.y = 0; + } + + step5[index] = (Quaternion.Euler(0, walkDirection, 0) * t2) / speed2; + + step6[index] = true; + } + else + { + Vector3 t2 = (legsInitial[index] + s[t].pos) - legs[index].GetComponent().point; + step5[index] = t2 / speed2; + + step6[index] = false; + freeze_y[index] = false; + } + } + else + { + step5[index] = new Vector3(0, 0, 0); + step6[index] = false; } } @@ -110,7 +219,16 @@ public class Walk : MonoBehaviour { for (int index = 0; index < legs.Count; ++index) { - legs[index].GetComponent().point += step2[index]; + legs[index].GetComponent().point += step5[index]; + if (step6[index]) + { + //legs[index].GetComponent().point += step5[index]; + + // rotate x,y around rotation. + legs[index].GetComponent().setWorldPos( + Quaternion.Euler(0, step2[index], 0) * legs[index].GetComponent().getWorldPos() + ); + } } } } diff --git a/Assets/Walk.cs.meta b/Assets/Walk.cs.meta index 72a7f4a..67297d2 100644 --- a/Assets/Walk.cs.meta +++ b/Assets/Walk.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 62866dc69f17c5f40a7ec527e34e82f1 -timeCreated: 1542141752 +guid: a4266f2a53eea3a43972b07e077212bc +timeCreated: 1542307321 licenseType: Free MonoImporter: externalObjects: {} diff --git a/Assets/Walk2.cs b/Assets/Walk2.cs deleted file mode 100644 index fbb7cc2..0000000 --- a/Assets/Walk2.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Walk2 : MonoBehaviour -{ - public List legs = new List(); - private List legsInitial = new List(); - - // Use this for initialization - void Start() - { - for (int index = 0; index < legs.Count; ++index) - { - legsInitial.Add(legs[index].GetComponent().point); - step2.Add(0); - step3.Add(0); - step4.Add(new Vector3(0, 0, 0)); - } - } - - struct step - { - public float rotation; - public float height; - public bool inAir; - - public step(float r, float h, bool i) - { - rotation = r; - height = h; - inAir = i; - } - } - - // 1, 3, 5 -= 3 - - int offset(int i, int offset, int max) - { - return i - offset < 0 ? (max - (offset - i)) : i - offset; - } - - step[] s = { - new step(-1, 0, false), - - new step(0, -2, false), - - new step(0, 0, false), // rest - - new step(1, 0, false), - new step(1, 0, false), - - new step(0, 0, false), // rest - - new step(0, 2, false), - new step(-1, 0, true), - }; - - public int st = 5; - public int speed2 = 30; - int speed = 10; - - public float rotation = 0; - - int size = 8; - - //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() - { - if (speed <= 0) - { - if (st >= size - 1) - st = 0; - else - st++; - - 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].inAir == false) - { - step2[index] = (rotation * s[t].rotation) / speed2; - step3[index] = s[t].height / speed2; - step4[index] = new Vector3(0, 0, 0); - } - else - { - Vector3 t2 = legsInitial[index] - legs[index].GetComponent().point; - step4[index] = t2 / speed2; - } - } - - speed = speed2; - } - else - { - speed--; - makestep(); - } - } - - void makestep() - { - for (int index = 0; index < legs.Count; ++index) - { - 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]; - } - } - } -} diff --git a/Assets/Walk2.cs.meta b/Assets/Walk2.cs.meta deleted file mode 100644 index 19644ec..0000000 --- a/Assets/Walk2.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 91e6f3895f276d94da1803128e6290e0 -timeCreated: 1542229569 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Walk3.cs b/Assets/Walk3.cs deleted file mode 100644 index 604f57c..0000000 --- a/Assets/Walk3.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Walk3 : MonoBehaviour -{ - public List legs = new List(); - private List legsInitial = new List(); - - // Use this for initialization - void Start() - { - for (int index = 0; index < legs.Count; ++index) - { - legsInitial.Add(legs[index].GetComponent().point); - step2.Add(0); - step6.Add(false); - //step3.Add(0); - //step4.Add(new Vector3(0, 0, 0)); - step5.Add(new Vector3()); - - freeze.Add(false); - freeze_y.Add(false); - } - } - - struct step - { - public Vector3 pos; - public float rotation; - public float height; - public bool inAir; - public bool inRest; - - public step(Vector3 p, float r, float h, bool i, bool ir) - { - pos = p; - rotation = r; - height = 0; - inAir = i; - inRest = ir; - } - } - - // 1, 3, 5 -= 3 - - int offset(int i, int offset, int max) - { - return i - offset < 0 ? (max - (offset - i)) : i - offset; - } - - step[] s = { - new step(new Vector3(-1, 0, 0), -1, 0, false, false), - - new step(new Vector3(0, -2, 0), 0, 0, false, false), - - new step(new Vector3(0, 0, 0), 0, 0, false, false), // rest - - 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, false), // rest - - 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; - public int speed2 = 30; - int speed = 10; - - public float walkDirection = 0; - public float centerRotation = 0; - - int size = 8; - - public float walkspeed = 1; - - private List step2 = new List(); - //private List step3 = new List(); - //private List step4 = new List(); - private List step5 = new List(); - private List step6 = new List(); - - private List freeze = new List(); - private List freeze_y = new List(); - - // Update is called once per frame - void FixedUpdate() - { - if (speed <= 0) - { - 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().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; - if (index == 1 || index == 3 || index == 5) - { - t = offset(st, 4, size); - } - - if (!freeze[index]) - { - 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. - if (freeze_y[index]) - { - t2.y = 0; - } - step5[index] = (Quaternion.Euler(0, walkDirection, 0) * t2) / speed2; - - step6[index] = true; - } - else - { - Vector3 t2 = (legsInitial[index] + s[t].pos) - legs[index].GetComponent().point; - step5[index] = t2 / speed2; - - step6[index] = false; - freeze_y[index] = false; - } - } - else - { - step5[index] = new Vector3(0, 0, 0); - step6[index] = false; - } - } - - speed = speed2; - } - else - { - speed--; - makestep(); - } - } - - void makestep() - { - for (int index = 0; index < legs.Count; ++index) - { - legs[index].GetComponent().point += step5[index]; - if (step6[index]) - { - //legs[index].GetComponent().point += step5[index]; - - // rotate x,y around rotation. - legs[index].GetComponent().setWorldPos( - Quaternion.Euler(0, step2[index], 0) * legs[index].GetComponent().getWorldPos() - ); - } - } - } -} diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 17c8f53..2aaa155 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -6,290 +6,98 @@ InputManager: serializedVersion: 2 m_Axes: - serializedVersion: 3 - m_Name: Horizontal + m_Name: 1 descriptiveName: descriptiveNegativeName: negativeButton: left positiveButton: right altNegativeButton: a altPositiveButton: d - gravity: 3 + gravity: 1 dead: 0.001 - sensitivity: 3 + sensitivity: 1 snap: 1 invert: 0 - type: 0 + type: 2 axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Vertical + m_Name: 2 descriptiveName: descriptiveNegativeName: negativeButton: down positiveButton: up altNegativeButton: s altPositiveButton: w - gravity: 3 + gravity: 1 dead: 0.001 - sensitivity: 3 + sensitivity: 1 snap: 1 invert: 0 - type: 0 - axis: 0 + type: 2 + axis: 1 joyNum: 0 - serializedVersion: 3 - m_Name: Fire1 + m_Name: 3 descriptiveName: descriptiveNegativeName: negativeButton: positiveButton: left ctrl altNegativeButton: altPositiveButton: mouse 0 - gravity: 1000 + gravity: 1 dead: 0.001 - sensitivity: 1000 - snap: 0 + sensitivity: 1 + snap: 1 invert: 0 - type: 0 - axis: 0 + type: 2 + axis: 2 joyNum: 0 - serializedVersion: 3 - m_Name: Fire2 + m_Name: 4 descriptiveName: descriptiveNegativeName: negativeButton: positiveButton: left alt altNegativeButton: altPositiveButton: mouse 1 - gravity: 1000 + gravity: 1 dead: 0.001 - sensitivity: 1000 - snap: 0 + sensitivity: 1 + snap: 1 invert: 0 - type: 0 - axis: 0 + type: 2 + axis: 3 joyNum: 0 - serializedVersion: 3 - m_Name: Fire3 + m_Name: 5 descriptiveName: descriptiveNegativeName: negativeButton: positiveButton: left shift altNegativeButton: altPositiveButton: mouse 2 - gravity: 1000 + gravity: 1 dead: 0.001 - sensitivity: 1000 - snap: 0 + sensitivity: 1 + snap: 1 invert: 0 - type: 0 - axis: 0 + type: 2 + axis: 4 joyNum: 0 - serializedVersion: 3 - m_Name: Jump + m_Name: 6 descriptiveName: descriptiveNegativeName: negativeButton: positiveButton: space altNegativeButton: altPositiveButton: - gravity: 1000 + gravity: 1 dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse X - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse Y - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse ScrollWheel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 2 - joyNum: 0 - - serializedVersion: 3 - m_Name: Horizontal - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 sensitivity: 1 - snap: 0 + snap: 1 invert: 0 type: 2 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Vertical - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 1 - type: 2 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 0 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 1 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 2 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Jump - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 3 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: return - altNegativeButton: - altPositiveButton: joystick button 0 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: enter - altNegativeButton: - altPositiveButton: space - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Cancel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: escape - altNegativeButton: - altPositiveButton: joystick button 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 + axis: 5 joyNum: 0