From 43e60d535a57c757f8ae2e3ca5bac4924b3cce10 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 4 Dec 2022 23:11:05 +0100 Subject: [PATCH] updated walk and controller input to joystick --- .../Hexapod/v15/Server/sqlite3/storage.ide | 4 +- .../v15/Server/sqlite3/storage.ide-shm | 2 +- .../v15/Server/sqlite3/storage.ide-wal | 4 +- 2018-unity-sim/Assets/Foot.cs | 8 +- 2018-unity-sim/Assets/JoyStick.meta | 10 + .../Assets/JoyStick/HandleHoystick.cs | 72 +++++ .../HandleHoystick.cs.meta} | 4 +- 2018-unity-sim/Assets/Leg.cs | 48 ++-- 2018-unity-sim/Assets/Main.unity | 4 +- 2018-unity-sim/Assets/RotationControl.cs | 16 +- 2018-unity-sim/Assets/Serial.cs | 67 ----- 2018-unity-sim/Assets/Serial.meta | 10 + 2018-unity-sim/Assets/Serial/Serial.cs | 119 ++++++++ .../Assets/{ => Serial}/Serial.cs.meta | 0 2018-unity-sim/Assets/{ => Serial}/Serial2.cs | 3 +- .../Assets/{ => Serial}/Serial2.cs.meta | 0 2018-unity-sim/Assets/Serial/Serial3.cs | 170 ++++++++++++ .../Assets/{ => Serial}/Serial3.cs.meta | 0 2018-unity-sim/Assets/Serial3.cs | 165 ------------ 2018-unity-sim/Assets/Walk.cs | 170 ++++++++++-- 2018-unity-sim/Assets/Walk.cs.meta | 4 +- 2018-unity-sim/Assets/Walk2.cs | 131 --------- 2018-unity-sim/Assets/Walk2.cs.meta | 13 - 2018-unity-sim/Assets/Walk3.cs | 202 -------------- .../ProjectSettings/InputManager.asset | 254 +++--------------- 25 files changed, 609 insertions(+), 871 deletions(-) create mode 100644 2018-unity-sim/Assets/JoyStick.meta create mode 100644 2018-unity-sim/Assets/JoyStick/HandleHoystick.cs rename 2018-unity-sim/Assets/{Walk3.cs.meta => JoyStick/HandleHoystick.cs.meta} (77%) delete mode 100644 2018-unity-sim/Assets/Serial.cs create mode 100644 2018-unity-sim/Assets/Serial.meta create mode 100644 2018-unity-sim/Assets/Serial/Serial.cs rename 2018-unity-sim/Assets/{ => Serial}/Serial.cs.meta (100%) rename 2018-unity-sim/Assets/{ => Serial}/Serial2.cs (98%) rename 2018-unity-sim/Assets/{ => Serial}/Serial2.cs.meta (100%) create mode 100644 2018-unity-sim/Assets/Serial/Serial3.cs rename 2018-unity-sim/Assets/{ => Serial}/Serial3.cs.meta (100%) delete mode 100644 2018-unity-sim/Assets/Serial3.cs delete mode 100644 2018-unity-sim/Assets/Walk2.cs delete mode 100644 2018-unity-sim/Assets/Walk2.cs.meta delete mode 100644 2018-unity-sim/Assets/Walk3.cs 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 cd568d2..22b813b 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:a1b91e2a145f9667d70b13198a5b3107c5f978327695ea68479520fa223e97ad -size 1032192 +oid sha256:fb1b045fab765d6e4727cad7634579ee74f002aebcd23bd485206d6334a262a2 +size 1040384 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 8da1c61..abd0e8e 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:2e29e44da33cbde8435eaf693d7d6e86584a9b7e11a564832a08565ee2270d7e +oid sha256:849f186132e524136abc5270c38be18c765db9085b78c3305ed426b14b20c82a 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 571f51a..e4a6eaa 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:2b2a7aec422e8200a35038518e5b7b915dfc90080b9d466db723d7e4e9b6b404 -size 4140632 +oid sha256:52b4e0760d65610d51ab1e442fd4c8e9b76cb5571a812bcb8594d3cb95b9a800 +size 3786312 diff --git a/2018-unity-sim/Assets/Foot.cs b/2018-unity-sim/Assets/Foot.cs index 6e38fb8..b53a6bb 100644 --- a/2018-unity-sim/Assets/Foot.cs +++ b/2018-unity-sim/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/2018-unity-sim/Assets/JoyStick.meta b/2018-unity-sim/Assets/JoyStick.meta new file mode 100644 index 0000000..9c4a1a1 --- /dev/null +++ b/2018-unity-sim/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/2018-unity-sim/Assets/JoyStick/HandleHoystick.cs b/2018-unity-sim/Assets/JoyStick/HandleHoystick.cs new file mode 100644 index 0000000..c2c914b --- /dev/null +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Walk3.cs.meta b/2018-unity-sim/Assets/JoyStick/HandleHoystick.cs.meta similarity index 77% rename from 2018-unity-sim/Assets/Walk3.cs.meta rename to 2018-unity-sim/Assets/JoyStick/HandleHoystick.cs.meta index 67297d2..cbe655b 100644 --- a/2018-unity-sim/Assets/Walk3.cs.meta +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Leg.cs b/2018-unity-sim/Assets/Leg.cs index a9095e3..43d791c 100644 --- a/2018-unity-sim/Assets/Leg.cs +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Main.unity b/2018-unity-sim/Assets/Main.unity index cc4b971..3867477 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:d9d8f9f9ab588af6ad767e7b01fd9e0b23cd6212c541eac0450a24d0875c5bf8 -size 9973394 +oid sha256:157f86a1cf17b5abdf560b35d4f752eadaaaf135056954a3484ae65e075d8fba +size 9973687 diff --git a/2018-unity-sim/Assets/RotationControl.cs b/2018-unity-sim/Assets/RotationControl.cs index 8d837fc..5f443a4 100644 --- a/2018-unity-sim/Assets/RotationControl.cs +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Serial.cs b/2018-unity-sim/Assets/Serial.cs deleted file mode 100644 index 39e31ba..0000000 --- a/2018-unity-sim/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/2018-unity-sim/Assets/Serial.meta b/2018-unity-sim/Assets/Serial.meta new file mode 100644 index 0000000..87b3f4c --- /dev/null +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Serial/Serial.cs b/2018-unity-sim/Assets/Serial/Serial.cs new file mode 100644 index 0000000..0c5a03d --- /dev/null +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Serial.cs.meta b/2018-unity-sim/Assets/Serial/Serial.cs.meta similarity index 100% rename from 2018-unity-sim/Assets/Serial.cs.meta rename to 2018-unity-sim/Assets/Serial/Serial.cs.meta diff --git a/2018-unity-sim/Assets/Serial2.cs b/2018-unity-sim/Assets/Serial/Serial2.cs similarity index 98% rename from 2018-unity-sim/Assets/Serial2.cs rename to 2018-unity-sim/Assets/Serial/Serial2.cs index ffe7715..86cfa95 100644 --- a/2018-unity-sim/Assets/Serial2.cs +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Serial2.cs.meta b/2018-unity-sim/Assets/Serial/Serial2.cs.meta similarity index 100% rename from 2018-unity-sim/Assets/Serial2.cs.meta rename to 2018-unity-sim/Assets/Serial/Serial2.cs.meta diff --git a/2018-unity-sim/Assets/Serial/Serial3.cs b/2018-unity-sim/Assets/Serial/Serial3.cs new file mode 100644 index 0000000..17dd6d9 --- /dev/null +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Serial3.cs.meta b/2018-unity-sim/Assets/Serial/Serial3.cs.meta similarity index 100% rename from 2018-unity-sim/Assets/Serial3.cs.meta rename to 2018-unity-sim/Assets/Serial/Serial3.cs.meta diff --git a/2018-unity-sim/Assets/Serial3.cs b/2018-unity-sim/Assets/Serial3.cs deleted file mode 100644 index 5277af8..0000000 --- a/2018-unity-sim/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/2018-unity-sim/Assets/Walk.cs b/2018-unity-sim/Assets/Walk.cs index 4ecba33..346e383 100644 --- a/2018-unity-sim/Assets/Walk.cs +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Walk.cs.meta b/2018-unity-sim/Assets/Walk.cs.meta index 72a7f4a..67297d2 100644 --- a/2018-unity-sim/Assets/Walk.cs.meta +++ b/2018-unity-sim/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/2018-unity-sim/Assets/Walk2.cs b/2018-unity-sim/Assets/Walk2.cs deleted file mode 100644 index fbb7cc2..0000000 --- a/2018-unity-sim/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/2018-unity-sim/Assets/Walk2.cs.meta b/2018-unity-sim/Assets/Walk2.cs.meta deleted file mode 100644 index 19644ec..0000000 --- a/2018-unity-sim/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/2018-unity-sim/Assets/Walk3.cs b/2018-unity-sim/Assets/Walk3.cs deleted file mode 100644 index 604f57c..0000000 --- a/2018-unity-sim/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/2018-unity-sim/ProjectSettings/InputManager.asset b/2018-unity-sim/ProjectSettings/InputManager.asset index 17c8f53..2aaa155 100644 --- a/2018-unity-sim/ProjectSettings/InputManager.asset +++ b/2018-unity-sim/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