1
0
Fork 0

Update BrakeBarController

This commit is contained in:
Unknown 2018-04-22 22:07:57 +02:00
parent ac7e058227
commit e76f819a0f

View file

@ -7,7 +7,8 @@ public class BrakeBarController : MonoBehaviour {
float currentRotation; float currentRotation;
int BrakeAmount = 100; int BrakeAmount = 100;
private Player player; private Player player;
int currentBrakeAmount; float firstTime;
float secondTime;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
@ -19,22 +20,31 @@ public class BrakeBarController : MonoBehaviour {
// if player alive and spawned // if player alive and spawned
if (player != null) if (player != null)
{ {
UpdatePointer(currentBrakeAmount); UpdatePointer();
} }
else if (currentRotation != 0) else if (currentRotation != 0)
{ {
//if player dead or not spawned //if player dead or not spawned
UpdatePointer(0); UpdatePointer();
} }
} }
private void UpdatePointer(float brakeAmount) private void UpdatePointer()
{ {
if (Input.GetKey(KeyCode.S)) { if (Input.GetKeyDown(KeyCode.S))
float offset = brakeAmount - currentRotation; {
gameObject.transform.Rotate(Vector3.forward, offset); firstTime = Time.time;
currentRotation += offset; }
if (Input.GetKeyUp(KeyCode.S))
{
secondTime = Time.time;
float difference = secondTime - firstTime;
gameObject.transform.Rotate(Vector3.forward, difference);
}
} }
} }
}