blob: a1f5017b1ebae0b53323d17fa074743fb3494afd (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Rigging.Data
{
public class StandingDataHandler : RiggingDataBase
{
public float sinceGrounded; // 离地时间
public float sinceLanded;
public bool isGrounded;
public float distanceToGround = 1f;
private bool hasRecievedTouchedGround;
private MovementDataHandler movementData;
protected override void OnStart()
{
movementData = player.status.movementData;
}
// 每帧都重置和刷新状态,而不是持续的维护bool值(容易出异常)
protected override void OnFixedUpdate()
{
sinceGrounded += Time.fixedDeltaTime;//
sinceLanded += Time.fixedDeltaTime;//
if ((double)sinceGrounded > 0.1)
{
isGrounded = false;//
}
}
protected override void OnLateUpdate()
{
hasRecievedTouchedGround = false;//
}
// 每帧都会检测和刷新状态,而不是维护bool值
public void TouchGround(float distance, Vector3 normal)
{
//if (sinceGrounded > 0.5f && (bool)wobbleShake)
//{
// wobbleShake.AddShake(-Vector3.up * 5f * Mathf.Pow(sinceGrounded, 1.5f), 0.8f);
//}
if (sinceGrounded > 0.5f)
{
Land(sinceGrounded);
}
sinceGrounded = 0f;
isGrounded = true;
if (distance > distanceToGround || !hasRecievedTouchedGround)
{
distanceToGround = distance;
}
hasRecievedTouchedGround = true;
//moveMentData.SetSlope(normal);
}
private void Land(float landForce)
{
sinceLanded = 0f;
}
}
}
|