blob: fd8110b0203986bd7e4fba5f5b6dfbe2ff61f465 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using UnityEngine;
public class StepHandler : MonoBehaviour
{
public float staticCounter;
public Step[] steps;
public bool isLeft;
private float counter;
private Transform leftLeg;
private Transform rightLeg;
private AnimationHandler animationHandler;
private Transform hip;
private void Start()
{
if (staticCounter == 0f)
{
leftLeg = GetComponentInChildren<LegLeft>().transform;
rightLeg = GetComponentInChildren<LegRight>().transform;
animationHandler = GetComponent<AnimationHandler>();
hip = GetComponentInChildren<Hip>().transform;
}
}
private void Update()
{
counter += Time.deltaTime;
if (staticCounter != 0f)
{
if (counter > staticCounter)
{
Switch();
}
}
else if (counter > steps[animationHandler.animationState].minTime && (steps[animationHandler.animationState].minAngle == 0f || steps[animationHandler.animationState].minAngle < Vector3.Angle(leftLeg.forward, rightLeg.forward)) && isLeft == hip.InverseTransformPoint(leftLeg.position + leftLeg.forward).z > hip.InverseTransformPoint(rightLeg.position + rightLeg.forward).z)
{
Switch();
}
}
private void Switch()
{
isLeft = !isLeft;
counter = 0f;
}
}
|