v5 ITS ALIVE, IT WALKS!

This commit is contained in:
2018-11-13 23:09:58 +01:00
parent 509a4e2d64
commit b505fe4618
8 changed files with 269 additions and 37 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+125 -12
View File
@@ -26953,7 +26953,7 @@ Transform:
- {fileID: 842799377}
- {fileID: 591879372}
m_Father: {fileID: 1971572978}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!1 &164769193
GameObject:
@@ -34419,7 +34419,7 @@ MonoBehaviour:
a1: 0
a2: 0
a3: 0
point: {x: 4, y: -15, z: -13}
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}
@@ -48706,6 +48706,7 @@ GameObject:
m_Component:
- component: {fileID: 311513961}
- component: {fileID: 311513962}
- component: {fileID: 311513963}
m_Layer: 0
m_Name: RotationControl
m_TagString: Untagged
@@ -48737,9 +48738,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 30ea8dc0510444c42ae4b4db1f5ee2bd, type: 3}
m_Name:
m_EditorClassIdentifier:
transformation: {x: 0, y: 3, z: 0}
transformation: {x: 0, y: 0, z: 0}
transformation2: {x: 0, y: 0, z: 0}
rotation: {x: 0, y: 0, z: 0, w: 0}
rotation: {x: -1, y: 0, z: 2, w: 0}
rotation2:
- {fileID: 636309705}
- {fileID: 596626244}
@@ -48749,6 +48750,28 @@ 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: 1
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: 5
rotation: 0
walkspeed: 1.5
--- !u!1 &311874317
GameObject:
m_ObjectHideFlags: 0
@@ -99396,7 +99419,7 @@ MonoBehaviour:
a1: 0
a2: 0
a3: 0
point: {x: -4, y: -15, z: 13}
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}
@@ -102418,7 +102441,7 @@ Transform:
- {fileID: 1440823284}
- {fileID: 914986743}
m_Father: {fileID: 1971572978}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &653632280
GameObject:
@@ -103633,7 +103656,7 @@ Transform:
- {fileID: 958514921}
- {fileID: 1943602707}
m_Father: {fileID: 1971572978}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &659284584
GameObject:
@@ -169380,7 +169403,7 @@ Transform:
- {fileID: 2042398688}
- {fileID: 955360345}
m_Father: {fileID: 1971572978}
m_RootOrder: 5
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!1 &1051905036
GameObject:
@@ -200110,7 +200133,7 @@ Transform:
- {fileID: 202055677}
- {fileID: 32992309}
m_Father: {fileID: 1971572978}
m_RootOrder: 6
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!1 &1245696998
GameObject:
@@ -234723,7 +234746,7 @@ MonoBehaviour:
a1: 0
a2: 0
a3: 0
point: {x: -4, y: -15, z: -13}
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}
@@ -245794,6 +245817,95 @@ Transform:
m_Father: {fileID: 228599798}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1525476315
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 1659089946116098, guid: 724361973d864ef4d957b37a51f94a9e,
type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1525476316}
- component: {fileID: 1525476319}
- component: {fileID: 1525476318}
- component: {fileID: 1525476317}
m_Layer: 0
m_Name: Cube (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1525476316
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 4666524806412162, guid: 724361973d864ef4d957b37a51f94a9e,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1525476315}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 5, y: 1, z: 13.5}
m_Children: []
m_Father: {fileID: 1971572978}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1525476317
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 23271557760752862, guid: 724361973d864ef4d957b37a51f94a9e,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1525476315}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!65 &1525476318
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 65851153276042954, guid: 724361973d864ef4d957b37a51f94a9e,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1525476315}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &1525476319
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 33292083258987710, guid: 724361973d864ef4d957b37a51f94a9e,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1525476315}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1526957864
GameObject:
m_ObjectHideFlags: 0
@@ -259157,7 +259269,7 @@ MonoBehaviour:
a1: 0
a2: 0
a3: 0
point: {x: 4, y: -15, z: 13}
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}
@@ -287105,7 +287217,7 @@ Transform:
- {fileID: 8323914}
- {fileID: 2018746517}
m_Father: {fileID: 1971572978}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1787902796
GameObject:
@@ -316142,6 +316254,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1389944204}
- {fileID: 1525476316}
- {fileID: 1786430462}
- {fileID: 653454402}
- {fileID: 658472411}
+2 -2
View File
@@ -81,9 +81,9 @@ public class RotationControl : MonoBehaviour
//rotation.y = r2.update();
//rotation.z = r3.update();
transformation.x = r4.update();
//transformation.x = r4.update();
//transformation.y = r5.update();
transformation.z = r6.update();
//transformation.z = r6.update();
/*transformation2.x = r7.update();
transformation2.y = r8.update();
+28 -23
View File
@@ -23,42 +23,47 @@ public class Serial {
}
}
public bool enabled = false;
SerialPort serialPort;
public void send(int start, int a, int b, int c)
{
if (serialPort == null)
if (enabled)
{
serialPort = new SerialPort(@"\\.\" + "COM10", 115200);
if (serialPort == null)
{
serialPort = new SerialPort(@"\\.\" + "COM10", 115200);
serialPort.Open();
serialPort.DiscardOutBuffer();
serialPort.DiscardInBuffer();
}
serialPort.Open();
serialPort.DiscardOutBuffer();
serialPort.DiscardInBuffer();
}
if (serialPort is SerialPort)
{
if (serialPort is SerialPort)
{
serialPort.Write(" #");
serialPort.Write(start.ToString());
serialPort.Write(" P");
serialPort.Write(a.ToString());
serialPort.Write(" #");
serialPort.Write(start.ToString());
serialPort.Write(" P");
serialPort.Write(a.ToString());
start++;
start++;
serialPort.Write(" #");
serialPort.Write(start.ToString());
serialPort.Write(" P");
serialPort.Write(b.ToString());
serialPort.Write(" #");
serialPort.Write(start.ToString());
serialPort.Write(" P");
serialPort.Write(b.ToString());
start++;
start++;
serialPort.Write(" #");
serialPort.Write(start.ToString());
serialPort.Write(" P");
serialPort.Write(c.ToString());
serialPort.Write(" #");
serialPort.Write(start.ToString());
serialPort.Write(" P");
serialPort.Write(c.ToString());
serialPort.Write(" \r");
serialPort.Write(" \r");
}
}
}
+101
View File
@@ -0,0 +1,101 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Walk : MonoBehaviour
{
public List<GameObject> legs = new List<GameObject>();
private List<Vector3> legsInitial = new List<Vector3>();
// Use this for initialization
void Start()
{
for (int index = 0; index < legs.Count; ++index)
{
legsInitial.Add(legs[index].GetComponent<Leg>().point);
}
}
struct step
{
public Vector3 pos;
public bool inAir;
public step(Vector3 p, bool i)
{
pos = p;
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(new Vector3(-1, 0, 0), false),
new step(new Vector3(0, -2, 0), false),
new step(new Vector3(0, 0, 0), false), // rest
new step(new Vector3(1, 0, 0), false),
new step(new Vector3(1, 0, 0), false),
new step(new Vector3(0, 0, 0), false), // rest
new step(new Vector3(0, 2, 0), true),
new step(new Vector3(-1, 0, 0), false),
};
public int st = 5;
public int speed2 = 30;
int speed = 10;
public float rotation = 0;
int size = 8;
public float walkspeed = 1;
// 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)
{
Vector3 t2 = s[t].pos;
t2.x *= walkspeed;
// rotate x,y around rotation.
legs[index].GetComponent<Leg>().point += Quaternion.Euler(0, rotation, 0) * t2;
}
else
{
legs[index].GetComponent<Leg>().point = legsInitial[index] + s[t].pos;
}
}
speed = speed2;
}
else
speed--;
}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 62866dc69f17c5f40a7ec527e34e82f1
timeCreated: 1542141752
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: