-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransitionSmoothingScript.cs
More file actions
108 lines (98 loc) · 2.04 KB
/
Copy pathTransitionSmoothingScript.cs
File metadata and controls
108 lines (98 loc) · 2.04 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using UnityEngine;
using System.Collections;
public class TransitionSmoothingScript : MonoBehaviour
{
//Smoothing for X
public float TransSmootherX;
public float TransHelperX;
public float TransSpeedX;
//Smoothing for Y
public float TransSmootherY;
public float TransHelperY;
public float TransSpeedY;
void Update ()
{
/////////////////////////////////
///////// FOR X //////////
/////////////////////////////////
if (TransHelperX > 1)
{
TransHelperX = 1;
}
else if (TransHelperX < -1)
{
TransHelperX = -1;
}
if (Input.GetKey (KeyCode.D))
{
TransHelperX += TransSpeedX;
TransSmootherX = Mathf.Clamp(TransHelperX, -1, 1);
}
else if (Input.GetKey (KeyCode.A))
{
TransHelperX -= TransSpeedX;
TransSmootherX = Mathf.Clamp(TransHelperX, -1, 1);
}
else
{
if(TransHelperX == 0)
{
}
else if(TransHelperX > 0.1)
{
TransHelperX -= TransSpeedX;
TransSmootherX = Mathf.Clamp(TransHelperX, -1, 1);
}
else if(TransHelperX < -0.1)
{
TransHelperX += TransSpeedX;
TransSmootherX = Mathf.Clamp(TransHelperX, -1, 1);
}
if(TransHelperX < 0.1 && TransHelperX > -0.1)
{
TransSmootherX = 0;
}
}
/////////////////////////////////
///////// FOR Y //////////
/////////////////////////////////
if (TransHelperY > 1)
{
TransHelperY = 1;
}
else if (TransHelperY < -1)
{
TransHelperY = -1;
}
if (Input.GetKey (KeyCode.W))
{
TransHelperY += TransSpeedY;
TransSmootherY = Mathf.Clamp(TransHelperY, -1, 1);
}
else if (Input.GetKey (KeyCode.S))
{
TransHelperY -= TransSpeedY;
TransSmootherY = Mathf.Clamp(TransHelperY, -1, 1);
}
else
{
if(TransHelperY == 0)
{
}
else if(TransHelperY > 0.1)
{
TransHelperY -= TransSpeedY;
TransSmootherY = Mathf.Clamp(TransHelperY, -1, 1);
}
else if(TransHelperY < -0.1)
{
TransHelperY += TransSpeedY;
TransSmootherY = Mathf.Clamp(TransHelperY, -1, 1);
}
if(TransHelperY < 0.1 && TransHelperY > -0.1)
{
TransSmootherY = 0;
}
}
}
}