blob: 2af0e4b372d6d72877218d651889820e9a7d3608 (
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
|
using UnityEngine;
//Player Standing 动作-站立
public class Standing : MonoBehaviour
{
public RigidbodyMovment[] rigsToLift; //Head, Torso
public AnimationCurve[] animationLiftCurves;
private StandingDataHandler standingData;
private AnimationHandler animationHandler;
public float offset;
private PlayerDeath death;
private Strength str;
private float muscleMultiplier = 1f;
private float legAngleMultiplier;
private MovementDataHandler moveData;
private void Start()
{
death = GetComponent<PlayerDeath>();
str = GetComponent<Strength>();
standingData = GetComponent<StandingDataHandler>();
moveData = GetComponent<MovementDataHandler>();
animationHandler = GetComponent<AnimationHandler>();
}
private void FixedUpdate()
{
if (!death.dead)
{
muscleMultiplier = str.strength;
if (standingData.isGrounded)
{
Stand(animationLiftCurves[animationHandler.animationState]);
}
}
}
private void Stand(AnimationCurve curve)
{
legAngleMultiplier = 1f;
RigidbodyMovment[] array = rigsToLift;
foreach (RigidbodyMovment rigidbodyMovment in array)
{
// 施加一个向上的力
rigidbodyMovment.rig.AddForce(Vector3.up * muscleMultiplier * rigidbodyMovment.force * legAngleMultiplier * curve.Evaluate(standingData.distanceToGround + offset + moveData.slopeVelocityStrenght * -0.2f), ForceMode.Acceleration);
}
}
}
|