v4 transformation after rotation added.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8
-3
@@ -26,8 +26,9 @@ public class Foot : Component
|
|||||||
public double O1, O2, O3;
|
public double O1, O2, O3;
|
||||||
|
|
||||||
public Vector3 transformation = new Vector3(0, 0, 0);
|
public Vector3 transformation = new Vector3(0, 0, 0);
|
||||||
|
public Vector3 transformation2 = new Vector3(0, 0, 0);
|
||||||
|
|
||||||
static float temp = 2;
|
static float knie_offset = 2;
|
||||||
|
|
||||||
void RL3()
|
void RL3()
|
||||||
{
|
{
|
||||||
@@ -40,7 +41,7 @@ public class Foot : Component
|
|||||||
l3 = l3 * -1;
|
l3 = l3 * -1;
|
||||||
|
|
||||||
//todo
|
//todo
|
||||||
l3 -= temp;
|
l3 -= knie_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
double FO1()
|
double FO1()
|
||||||
@@ -63,7 +64,7 @@ public class Foot : Component
|
|||||||
double z2 = Z * Z;
|
double z2 = Z * Z;
|
||||||
|
|
||||||
double t = Math.Sqrt(x2 + z2);
|
double t = Math.Sqrt(x2 + z2);
|
||||||
t -= temp;
|
t -= knie_offset;
|
||||||
t = t * t;
|
t = t * t;
|
||||||
//todo: X,Z remove distance temp.
|
//todo: X,Z remove distance temp.
|
||||||
s = Math.Sqrt(y2 + t);
|
s = Math.Sqrt(y2 + t);
|
||||||
@@ -156,6 +157,10 @@ public class Foot : Component
|
|||||||
Y = v.y;
|
Y = v.y;
|
||||||
Z = v.z;
|
Z = v.z;
|
||||||
|
|
||||||
|
X -= transformation2.x;
|
||||||
|
Y -= transformation2.y;
|
||||||
|
Z -= transformation2.z;
|
||||||
|
|
||||||
X -= translateX;
|
X -= translateX;
|
||||||
Y -= translateY;
|
Y -= translateY;
|
||||||
Z -= translateZ;
|
Z -= translateZ;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class Leg : MonoBehaviour {
|
|||||||
public Quaternion rotation = new Quaternion(0, 0, 0, 0);
|
public Quaternion rotation = new Quaternion(0, 0, 0, 0);
|
||||||
|
|
||||||
public Vector3 transformation = new Vector3(0, 0, 0);
|
public Vector3 transformation = new Vector3(0, 0, 0);
|
||||||
|
public Vector3 transformation2 = new Vector3(0, 0, 0);
|
||||||
|
|
||||||
public bool invert = false;
|
public bool invert = false;
|
||||||
|
|
||||||
@@ -47,8 +48,12 @@ public class Leg : MonoBehaviour {
|
|||||||
foot.translateY = translateY;
|
foot.translateY = translateY;
|
||||||
foot.translateZ = translateZ;
|
foot.translateZ = translateZ;
|
||||||
|
|
||||||
|
// transform before rotation.
|
||||||
foot.transformation = transformation;
|
foot.transformation = transformation;
|
||||||
|
|
||||||
|
// transform after rotation.
|
||||||
|
foot.transformation2 = transformation2;
|
||||||
|
|
||||||
foot.invert = invert;
|
foot.invert = invert;
|
||||||
|
|
||||||
foot.setleg();
|
foot.setleg();
|
||||||
|
|||||||
+63
-23
@@ -26945,14 +26945,14 @@ Transform:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1453644144}
|
m_GameObject: {fileID: 1453644144}
|
||||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
m_LocalRotation: {x: -0, y: 1, z: -0, w: 0}
|
||||||
m_LocalPosition: {x: -5, y: 0, z: -5}
|
m_LocalPosition: {x: -5, y: 0, z: -5}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1945642084}
|
- {fileID: 1945642084}
|
||||||
- {fileID: 842799377}
|
- {fileID: 842799377}
|
||||||
- {fileID: 591879372}
|
- {fileID: 591879372}
|
||||||
m_Father: {fileID: 2129559091}
|
m_Father: {fileID: 1971572978}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||||
--- !u!1 &164769193
|
--- !u!1 &164769193
|
||||||
@@ -34422,6 +34422,7 @@ MonoBehaviour:
|
|||||||
point: {x: 4, y: -10, z: -13}
|
point: {x: 4, y: -10, z: -13}
|
||||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||||
transformation: {x: 0, y: 0, z: 0}
|
transformation: {x: 0, y: 0, z: 0}
|
||||||
|
transformation2: {x: 0, y: 0, z: 0}
|
||||||
invert: 1
|
invert: 1
|
||||||
translateX: 5
|
translateX: 5
|
||||||
translateY: 0
|
translateY: 0
|
||||||
@@ -48736,6 +48737,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
transformation: {x: 0, y: 0, 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: 0, y: 0, z: 0, w: 0}
|
||||||
rotation2:
|
rotation2:
|
||||||
- {fileID: 636309705}
|
- {fileID: 636309705}
|
||||||
@@ -48745,6 +48747,7 @@ MonoBehaviour:
|
|||||||
- {fileID: 1772413224}
|
- {fileID: 1772413224}
|
||||||
- {fileID: 210611261}
|
- {fileID: 210611261}
|
||||||
body: {fileID: 2129559090}
|
body: {fileID: 2129559090}
|
||||||
|
body2: {fileID: 1971572977}
|
||||||
min: -25
|
min: -25
|
||||||
max: 25
|
max: 25
|
||||||
speed: 0.1
|
speed: 0.1
|
||||||
@@ -48753,9 +48756,12 @@ MonoBehaviour:
|
|||||||
dir: 0
|
dir: 0
|
||||||
dir2: 0
|
dir2: 0
|
||||||
dir3: 0
|
dir3: 0
|
||||||
p: 1
|
p: 0
|
||||||
r: 1
|
r: 0
|
||||||
y: 1
|
y: 0
|
||||||
|
p2: 0
|
||||||
|
r2: 0
|
||||||
|
y2: 0
|
||||||
--- !u!1 &311874317
|
--- !u!1 &311874317
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -92882,6 +92888,7 @@ MonoBehaviour:
|
|||||||
point: {x: 0, y: -10, z: 15}
|
point: {x: 0, y: -10, z: 15}
|
||||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||||
transformation: {x: 0, y: 0, z: 0}
|
transformation: {x: 0, y: 0, z: 0}
|
||||||
|
transformation2: {x: 0, y: 0, z: 0}
|
||||||
invert: 0
|
invert: 0
|
||||||
translateX: 0
|
translateX: 0
|
||||||
translateY: 0
|
translateY: 0
|
||||||
@@ -99404,6 +99411,7 @@ MonoBehaviour:
|
|||||||
point: {x: -4, y: -10, z: 13}
|
point: {x: -4, y: -10, z: 13}
|
||||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||||
transformation: {x: 0, y: 0, z: 0}
|
transformation: {x: 0, y: 0, z: 0}
|
||||||
|
transformation2: {x: 0, y: 0, z: 0}
|
||||||
invert: 0
|
invert: 0
|
||||||
translateX: -5
|
translateX: -5
|
||||||
translateY: 0
|
translateY: 0
|
||||||
@@ -102413,14 +102421,14 @@ Transform:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 596626244}
|
m_GameObject: {fileID: 596626244}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 5}
|
m_LocalPosition: {x: 0, y: 0, z: 5}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1668338011}
|
- {fileID: 1668338011}
|
||||||
- {fileID: 1440823284}
|
- {fileID: 1440823284}
|
||||||
- {fileID: 914986743}
|
- {fileID: 914986743}
|
||||||
m_Father: {fileID: 2129559091}
|
m_Father: {fileID: 1971572978}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &653632280
|
--- !u!1 &653632280
|
||||||
@@ -103628,14 +103636,14 @@ Transform:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1619174560}
|
m_GameObject: {fileID: 1619174560}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 5, y: 0, z: 5}
|
m_LocalPosition: {x: 5, y: 0, z: 5}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 555867950}
|
- {fileID: 555867950}
|
||||||
- {fileID: 958514921}
|
- {fileID: 958514921}
|
||||||
- {fileID: 1943602707}
|
- {fileID: 1943602707}
|
||||||
m_Father: {fileID: 2129559091}
|
m_Father: {fileID: 1971572978}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &659284584
|
--- !u!1 &659284584
|
||||||
@@ -169375,14 +169383,14 @@ Transform:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1772413224}
|
m_GameObject: {fileID: 1772413224}
|
||||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
m_LocalRotation: {x: -0, y: 1, z: -0, w: 0}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: -5}
|
m_LocalPosition: {x: 0, y: 0, z: -5}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1718712321}
|
- {fileID: 1718712321}
|
||||||
- {fileID: 2042398688}
|
- {fileID: 2042398688}
|
||||||
- {fileID: 955360345}
|
- {fileID: 955360345}
|
||||||
m_Father: {fileID: 2129559091}
|
m_Father: {fileID: 1971572978}
|
||||||
m_RootOrder: 5
|
m_RootOrder: 5
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||||
--- !u!1 &1051905036
|
--- !u!1 &1051905036
|
||||||
@@ -200105,14 +200113,14 @@ Transform:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 210611261}
|
m_GameObject: {fileID: 210611261}
|
||||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
m_LocalRotation: {x: -0, y: 1, z: -0, w: 0}
|
||||||
m_LocalPosition: {x: 5, y: 0, z: -5}
|
m_LocalPosition: {x: 5, y: 0, z: -5}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1114772579}
|
- {fileID: 1114772579}
|
||||||
- {fileID: 202055677}
|
- {fileID: 202055677}
|
||||||
- {fileID: 32992309}
|
- {fileID: 32992309}
|
||||||
m_Father: {fileID: 2129559091}
|
m_Father: {fileID: 1971572978}
|
||||||
m_RootOrder: 6
|
m_RootOrder: 6
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||||
--- !u!1 &1245696998
|
--- !u!1 &1245696998
|
||||||
@@ -223926,7 +223934,7 @@ Transform:
|
|||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 10, y: 1, z: 10}
|
m_LocalScale: {x: 10, y: 1, z: 10}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 2129559091}
|
m_Father: {fileID: 1971572978}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &1389944205
|
--- !u!23 &1389944205
|
||||||
@@ -234729,6 +234737,7 @@ MonoBehaviour:
|
|||||||
point: {x: -4, y: -10, z: -13}
|
point: {x: -4, y: -10, z: -13}
|
||||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||||
transformation: {x: 0, y: 0, z: 0}
|
transformation: {x: 0, y: 0, z: 0}
|
||||||
|
transformation2: {x: 0, y: 0, z: 0}
|
||||||
invert: 1
|
invert: 1
|
||||||
translateX: -5
|
translateX: -5
|
||||||
translateY: 0
|
translateY: 0
|
||||||
@@ -259161,6 +259170,7 @@ MonoBehaviour:
|
|||||||
point: {x: 4, y: -10, z: 13}
|
point: {x: 4, y: -10, z: 13}
|
||||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||||
transformation: {x: 0, y: 0, z: 0}
|
transformation: {x: 0, y: 0, z: 0}
|
||||||
|
transformation2: {x: 0, y: 0, z: 0}
|
||||||
invert: 0
|
invert: 0
|
||||||
translateX: 5
|
translateX: 5
|
||||||
translateY: 0
|
translateY: 0
|
||||||
@@ -283860,6 +283870,7 @@ MonoBehaviour:
|
|||||||
point: {x: 0, y: -10, z: -15}
|
point: {x: 0, y: -10, z: -15}
|
||||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||||
transformation: {x: 0, y: 0, z: 0}
|
transformation: {x: 0, y: 0, z: 0}
|
||||||
|
transformation2: {x: 0, y: 0, z: 0}
|
||||||
invert: 1
|
invert: 1
|
||||||
translateX: 0
|
translateX: 0
|
||||||
translateY: 0
|
translateY: 0
|
||||||
@@ -287094,14 +287105,14 @@ Transform:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 636309705}
|
m_GameObject: {fileID: 636309705}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: -5, y: 0, z: 5}
|
m_LocalPosition: {x: -5, y: 0, z: 5}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1315959229}
|
- {fileID: 1315959229}
|
||||||
- {fileID: 8323914}
|
- {fileID: 8323914}
|
||||||
- {fileID: 2018746517}
|
- {fileID: 2018746517}
|
||||||
m_Father: {fileID: 2129559091}
|
m_Father: {fileID: 1971572978}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1787902796
|
--- !u!1 &1787902796
|
||||||
@@ -316113,6 +316124,41 @@ MeshFilter:
|
|||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1971451030}
|
m_GameObject: {fileID: 1971451030}
|
||||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!1 &1971572977
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 0}
|
||||||
|
serializedVersion: 5
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1971572978}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameObject
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1971572978
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1971572977}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 1389944204}
|
||||||
|
- {fileID: 1786430462}
|
||||||
|
- {fileID: 653454402}
|
||||||
|
- {fileID: 658472411}
|
||||||
|
- {fileID: 163545139}
|
||||||
|
- {fileID: 1051547784}
|
||||||
|
- {fileID: 1245260121}
|
||||||
|
m_Father: {fileID: 2129559091}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1971697617
|
--- !u!1 &1971697617
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -338910,13 +338956,7 @@ Transform:
|
|||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1389944204}
|
- {fileID: 1971572978}
|
||||||
- {fileID: 1786430462}
|
|
||||||
- {fileID: 653454402}
|
|
||||||
- {fileID: 658472411}
|
|
||||||
- {fileID: 163545139}
|
|
||||||
- {fileID: 1051547784}
|
|
||||||
- {fileID: 1245260121}
|
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|||||||
+73
-61
@@ -2,22 +2,72 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class RotationControl : MonoBehaviour
|
public class rotation
|
||||||
{
|
{
|
||||||
public Quaternion rotation = new Quaternion(0, 0, 0, 0);
|
|
||||||
public List<GameObject> rotation2 = new List<GameObject>();
|
|
||||||
public GameObject body;
|
|
||||||
|
|
||||||
public float min = -15;
|
public float min = -15;
|
||||||
public float max = 15;
|
public float max = 15;
|
||||||
public float speed = 0.3f;
|
public float speed = 0.3f;
|
||||||
public float speed2 = 0.3f;
|
|
||||||
public float speed3 = 0.3f;
|
|
||||||
public bool dir = false;
|
public bool dir = false;
|
||||||
public bool dir2 = false;
|
public bool enabled = true;
|
||||||
public bool dir3 = false;
|
|
||||||
|
|
||||||
public bool p = false, r = false, y = false;
|
public float i = 0;
|
||||||
|
|
||||||
|
public rotation(float speed, float min, float max)
|
||||||
|
{
|
||||||
|
this.speed = speed;
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float update()
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
if (!dir && i < max)
|
||||||
|
{
|
||||||
|
i += speed;
|
||||||
|
}
|
||||||
|
else if (!dir)
|
||||||
|
{
|
||||||
|
dir = !dir;
|
||||||
|
i = (float)max;
|
||||||
|
}
|
||||||
|
else if (dir && i > min)
|
||||||
|
{
|
||||||
|
i -= speed;
|
||||||
|
}
|
||||||
|
else if (dir)
|
||||||
|
{
|
||||||
|
dir = !dir;
|
||||||
|
i = (float)min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RotationControl : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Vector3 transformation = new Vector3(0, 0, 0);
|
||||||
|
public Vector3 transformation2 = new Vector3(0, 0, 0);
|
||||||
|
|
||||||
|
public Quaternion rotation = new Quaternion(0, 0, 0, 0);
|
||||||
|
public List<GameObject> rotation2 = new List<GameObject>();
|
||||||
|
public GameObject body;
|
||||||
|
public GameObject body2;
|
||||||
|
|
||||||
|
public rotation r1 = new rotation(0.1f, -15, 15);
|
||||||
|
public rotation r2 = new rotation(0.2f, -15, 15);
|
||||||
|
public rotation r3 = new rotation(0.3f, -15, 15);
|
||||||
|
|
||||||
|
public rotation r4 = new rotation(0.01f, -3, 3);
|
||||||
|
public rotation r5 = new rotation(0.02f, -3, 3);
|
||||||
|
public rotation r6 = new rotation(0.03f, -3, 3);
|
||||||
|
|
||||||
|
public rotation r7 = new rotation(0.001f, -3, 3);
|
||||||
|
public rotation r8 = new rotation(0.002f, -3, 3);
|
||||||
|
public rotation r9 = new rotation(0.003f, -3, 3);
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start ()
|
void Start ()
|
||||||
@@ -27,65 +77,27 @@ public class RotationControl : MonoBehaviour
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (p)
|
rotation.x = r1.update();
|
||||||
{
|
rotation.y = r2.update();
|
||||||
if (!dir2 && rotation.x < max)
|
rotation.z = r3.update();
|
||||||
rotation.x += speed2;
|
|
||||||
else if (!dir2)
|
|
||||||
{
|
|
||||||
dir2 = !dir2;
|
|
||||||
rotation.x = (float)max;
|
|
||||||
}
|
|
||||||
else if (dir2 && rotation.x > min)
|
|
||||||
rotation.x -= speed2;
|
|
||||||
else if (dir2)
|
|
||||||
{
|
|
||||||
dir2 = !dir2;
|
|
||||||
rotation.x = (float)min;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r)
|
transformation.x = r4.update();
|
||||||
{
|
transformation.y = r5.update();
|
||||||
if (!dir3 && rotation.y < max)
|
transformation.z = r6.update();
|
||||||
rotation.y += speed3;
|
|
||||||
else if (!dir3)
|
|
||||||
{
|
|
||||||
dir3 = !dir3;
|
|
||||||
rotation.y = (float)max;
|
|
||||||
}
|
|
||||||
else if (dir3 && rotation.y > min)
|
|
||||||
rotation.y -= speed3;
|
|
||||||
else if (dir3)
|
|
||||||
{
|
|
||||||
dir3 = !dir3;
|
|
||||||
rotation.y = (float)min;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y)
|
transformation2.x = r7.update();
|
||||||
{
|
transformation2.y = r8.update();
|
||||||
if (!dir && rotation.z < max)
|
transformation2.z = r9.update();
|
||||||
rotation.z += speed;
|
|
||||||
else if (!dir)
|
|
||||||
{
|
|
||||||
dir = !dir;
|
|
||||||
rotation.z = (float)max;
|
|
||||||
}
|
|
||||||
else if (dir && rotation.z > min)
|
|
||||||
rotation.z -= speed;
|
|
||||||
else if (dir)
|
|
||||||
{
|
|
||||||
dir = !dir;
|
|
||||||
rotation.z = (float)min;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y*-1, rotation.z*-1);
|
body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y*-1, rotation.z*-1);
|
||||||
|
body.transform.position = transformation;
|
||||||
|
body2.transform.localPosition = transformation2;
|
||||||
|
|
||||||
for (int index = 0; index < rotation2.Count; ++index)
|
for (int index = 0; index < rotation2.Count; ++index)
|
||||||
{
|
{
|
||||||
rotation2[index].GetComponent<Leg>().rotation = rotation;
|
rotation2[index].GetComponent<Leg>().rotation = rotation;
|
||||||
|
rotation2[index].GetComponent<Leg>().transformation = transformation;
|
||||||
|
rotation2[index].GetComponent<Leg>().transformation2 = transformation2;
|
||||||
rotation2[index].GetComponent<Leg>().FixedUpdate();
|
rotation2[index].GetComponent<Leg>().FixedUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user