Initial commit
This commit is contained in:
1 parent
ee9615239e
commit
16feac691f
4093 files changed
+1030491
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace UnityStandardAssets.Utility
|
||||
{
|
||||
[Serializable]
|
||||
public class CurveControlledBob
|
||||
{
|
||||
public float HorizontalBobRange = 0.33f;
|
||||
public float VerticalBobRange = 0.33f;
|
||||
public AnimationCurve Bobcurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(0.5f, 1f),
|
||||
new Keyframe(1f, 0f), new Keyframe(1.5f, -1f),
|
||||
new Keyframe(2f, 0f)); // sin curve for head bob
|
||||
public float VerticaltoHorizontalRatio = 1f;
|
||||
|
||||
private float m_CyclePositionX;
|
||||
private float m_CyclePositionY;
|
||||
private float m_BobBaseInterval;
|
||||
private Vector3 m_OriginalCameraPosition;
|
||||
private float m_Time;
|
||||
|
||||
|
||||
public void Setup(Camera camera, float bobBaseInterval)
|
||||
{
|
||||
m_BobBaseInterval = bobBaseInterval;
|
||||
m_OriginalCameraPosition = camera.transform.localPosition;
|
||||
|
||||
// get the length of the curve in time
|
||||
m_Time = Bobcurve[Bobcurve.length - 1].time;
|
||||
}
|
||||
|
||||
|
||||
public Vector3 DoHeadBob(float speed)
|
||||
{
|
||||
float xPos = m_OriginalCameraPosition.x + (Bobcurve.Evaluate(m_CyclePositionX)*HorizontalBobRange);
|
||||
float yPos = m_OriginalCameraPosition.y + (Bobcurve.Evaluate(m_CyclePositionY)*VerticalBobRange);
|
||||
|
||||
m_CyclePositionX += (speed*Time.deltaTime)/m_BobBaseInterval;
|
||||
m_CyclePositionY += ((speed*Time.deltaTime)/m_BobBaseInterval)*VerticaltoHorizontalRatio;
|
||||
|
||||
if (m_CyclePositionX > m_Time)
|
||||
{
|
||||
m_CyclePositionX = m_CyclePositionX - m_Time;
|
||||
}
|
||||
if (m_CyclePositionY > m_Time)
|
||||
{
|
||||
m_CyclePositionY = m_CyclePositionY - m_Time;
|
||||
}
|
||||
|
||||
return new Vector3(xPos, yPos, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 492f54f4accf00440828ffcb9e4fcc19
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.Utility
|
||||
{
|
||||
[Serializable]
|
||||
public class FOVKick
|
||||
{
|
||||
public Camera Camera; // optional camera setup, if null the main camera will be used
|
||||
[HideInInspector] public float originalFov; // the original fov
|
||||
public float FOVIncrease = 3f; // the amount the field of view increases when going into a run
|
||||
public float TimeToIncrease = 1f; // the amount of time the field of view will increase over
|
||||
public float TimeToDecrease = 1f; // the amount of time the field of view will take to return to its original size
|
||||
public AnimationCurve IncreaseCurve;
|
||||
|
||||
|
||||
public void Setup(Camera camera)
|
||||
{
|
||||
CheckStatus(camera);
|
||||
|
||||
Camera = camera;
|
||||
originalFov = camera.fieldOfView;
|
||||
}
|
||||
|
||||
|
||||
private void CheckStatus(Camera camera)
|
||||
{
|
||||
if (camera == null)
|
||||
{
|
||||
throw new Exception("FOVKick camera is null, please supply the camera to the constructor");
|
||||
}
|
||||
|
||||
if (IncreaseCurve == null)
|
||||
{
|
||||
throw new Exception(
|
||||
"FOVKick Increase curve is null, please define the curve for the field of view kicks");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ChangeCamera(Camera camera)
|
||||
{
|
||||
Camera = camera;
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator FOVKickUp()
|
||||
{
|
||||
float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease);
|
||||
while (t < TimeToIncrease)
|
||||
{
|
||||
Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToIncrease)*FOVIncrease);
|
||||
t += Time.deltaTime;
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator FOVKickDown()
|
||||
{
|
||||
float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease);
|
||||
while (t > 0)
|
||||
{
|
||||
Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToDecrease)*FOVIncrease);
|
||||
t -= Time.deltaTime;
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
//make sure that fov returns to the original size
|
||||
Camera.fieldOfView = originalFov;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6045a93fb05b9c74884821030da2c46c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.Utility
|
||||
{
|
||||
[Serializable]
|
||||
public class LerpControlledBob
|
||||
{
|
||||
public float BobDuration;
|
||||
public float BobAmount;
|
||||
|
||||
private float m_Offset = 0f;
|
||||
|
||||
|
||||
// provides the offset that can be used
|
||||
public float Offset()
|
||||
{
|
||||
return m_Offset;
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator DoBobCycle()
|
||||
{
|
||||
// make the camera move down slightly
|
||||
float t = 0f;
|
||||
while (t < BobDuration)
|
||||
{
|
||||
m_Offset = Mathf.Lerp(0f, BobAmount, t/BobDuration);
|
||||
t += Time.deltaTime;
|
||||
yield return new WaitForFixedUpdate();
|
||||
}
|
||||
|
||||
// make it move back to neutral
|
||||
t = 0f;
|
||||
while (t < BobDuration)
|
||||
{
|
||||
m_Offset = Mathf.Lerp(BobAmount, 0f, t/BobDuration);
|
||||
t += Time.deltaTime;
|
||||
yield return new WaitForFixedUpdate();
|
||||
}
|
||||
m_Offset = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1bbfafbde15c854681023b9e01e12dd
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
Reference in new issue
Block a user