beautify
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@ public class Foot : Component
|
|||||||
RotateY();
|
RotateY();
|
||||||
RotateZ();*/
|
RotateZ();*/
|
||||||
|
|
||||||
// Z and X is working. Y has problems when combined with others.
|
// the order of these rotation transformations is important!!!
|
||||||
Vector3 v = new Vector3((float)X, (float)Y, (float)Z);
|
Vector3 v = new Vector3((float)X, (float)Y, (float)Z);
|
||||||
v = Quaternion.Euler((float)0, (float)rotationY, (float)0) * v;
|
v = Quaternion.Euler((float)0, (float)rotationY, (float)0) * v;
|
||||||
v = Quaternion.Euler((float)rotationX, (float)0, (float)0) * v;
|
v = Quaternion.Euler((float)rotationX, (float)0, (float)0) * v;
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ public class Leg : MonoBehaviour {
|
|||||||
|
|
||||||
public bool invert = false;
|
public bool invert = false;
|
||||||
|
|
||||||
public double translateX = 5;
|
public double translateX = 0;
|
||||||
public double translateY = 0;
|
public double translateY = 0;
|
||||||
public double translateZ = 0;
|
public double translateZ = 0;
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public class Leg : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
public void FixedUpdate()
|
||||||
{
|
{
|
||||||
foot.X = point.x;
|
foot.X = point.x;
|
||||||
foot.Y = point.y;
|
foot.Y = point.y;
|
||||||
|
|||||||
+341754
-576
File diff suppressed because it is too large
Load Diff
+60
-30
@@ -8,14 +8,16 @@ public class RotationControl : MonoBehaviour
|
|||||||
public List<GameObject> rotation2 = new List<GameObject>();
|
public List<GameObject> rotation2 = new List<GameObject>();
|
||||||
public GameObject body;
|
public GameObject body;
|
||||||
|
|
||||||
public double min = -15;
|
public float min = -15;
|
||||||
public double max = 15;
|
public float max = 15;
|
||||||
public float speed = 0.3f;
|
public float speed = 0.3f;
|
||||||
public float speed2 = 0.3f;
|
public float speed2 = 0.3f;
|
||||||
public float speed3 = 0.3f;
|
public float speed3 = 0.3f;
|
||||||
bool dir = false;
|
public bool dir = false;
|
||||||
bool dir2 = false;
|
public bool dir2 = false;
|
||||||
bool dir3 = false;
|
public bool dir3 = false;
|
||||||
|
|
||||||
|
public bool p = false, r = false, y = false;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start ()
|
void Start ()
|
||||||
@@ -23,40 +25,68 @@ public class RotationControl : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (!dir2 && rotation.x < max)
|
if (p)
|
||||||
rotation.x += speed2;
|
{
|
||||||
else if (!dir2)
|
if (!dir2 && rotation.x < max)
|
||||||
dir2 = !dir2;
|
rotation.x += speed2;
|
||||||
else if (dir2 && rotation.x > min)
|
else if (!dir2)
|
||||||
rotation.x -= speed2;
|
{
|
||||||
else if (dir2)
|
dir2 = !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 (!dir3 && rotation.y < max)
|
if (r)
|
||||||
rotation.y += speed3;
|
{
|
||||||
else if (!dir3)
|
if (!dir3 && rotation.y < max)
|
||||||
dir3 = !dir3;
|
rotation.y += speed3;
|
||||||
else if (dir3 && rotation.y > min)
|
else if (!dir3)
|
||||||
rotation.y -= speed3;
|
{
|
||||||
else if (dir3)
|
dir3 = !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 (!dir && rotation.z < max)
|
if (y)
|
||||||
rotation.z += speed;
|
{
|
||||||
else if (!dir)
|
if (!dir && rotation.z < max)
|
||||||
dir = !dir;
|
rotation.z += speed;
|
||||||
else if (dir && rotation.z > min)
|
else if (!dir)
|
||||||
rotation.z -= speed;
|
{
|
||||||
else if (dir)
|
dir = !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);
|
||||||
|
|
||||||
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>().FixedUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user