blob: 08e274ae9219f8dbc05d3876cae00a948209f5d3 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
using Rigging.BodyPart;
using Rigging.Data;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Rigging.Cameras
{
public class CameraMovement : MonoBehaviour
{
public Player player;
public Camera camera;
public Transform positionTarget;
public Transform rotationTarget;
private StandingDataHandler standingData;
private float fallingValue;
private float fallingEffectValue;
private float minBobble = 0.02f;
public bool ADS;
private Rigidbody hip;
private MovementDataHandler movementData;
private Rigidbody torso;
private Strength str;
private Vector3 cameraCurrentRelativeADSPosition = Vector3.zero;
private Vector3 movementADSVelocity = Vector3.zero;
private Vector3 ADSMovementPosition = Vector3.zero;
private void Start()
{
torso = base.transform.root.GetComponentInChildren<Torso>().GetComponent<Rigidbody>();
standingData = base.transform.root.GetComponentInChildren<StandingDataHandler>();
movementData = base.transform.root.GetComponentInChildren<MovementDataHandler>();
camera = GetComponentInChildren<Camera>();
hip = player.body.hip.rigidbody;
str = base.transform.root.GetComponentInChildren<Strength>();
}
private void LateUpdate()
{
if (standingData.sinceLanded > 1f)
{
fallingValue = Mathf.Clamp(standingData.sinceGrounded - 0.5f, 0f, 10f) * 0.5f;
}
if (standingData.sinceGrounded > 0.5f || standingData.sinceLanded < 0.5f)
{
fallingEffectValue = Mathf.Lerp(fallingEffectValue, fallingValue, Time.smoothDeltaTime * 15f);
}
else
{
fallingEffectValue = Mathf.Lerp(fallingEffectValue, minBobble, Time.smoothDeltaTime * 3f);
}
Vector3 position = positionTarget.position;
base.transform.position = position;
base.transform.rotation = rotationTarget.rotation;
SetCameraPosition();
}
private void SetCameraPosition()
{
camera.transform.localPosition = Vector3.Lerp(camera.transform.localPosition, Vector3.zero, Time.deltaTime * 20f);
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, 90f, Time.deltaTime * 20f);
}
private void FixedUpdate()
{
}
private void Update()
{
}
}
}
|