1
This commit is contained in:
17
Packages/Common~/Extensions/FPS/BITKit.FPS.asmdef
Normal file
17
Packages/Common~/Extensions/FPS/BITKit.FPS.asmdef
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "BITKit.FPS",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Packages/Common~/Extensions/FPS/BITKit.FPS.asmdef.meta
Normal file
7
Packages/Common~/Extensions/FPS/BITKit.FPS.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57f974f364e53c144ab01f57733e749d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
31
Packages/Common~/Extensions/FPS/Recoil.cs
Normal file
31
Packages/Common~/Extensions/FPS/Recoil.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
/* using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit.FPS
|
||||
{
|
||||
public class Recoil : MonoBehaviour
|
||||
{
|
||||
SpringEulerAngle recoilTarget;
|
||||
public float damp = 20;
|
||||
public float frequence = 15;
|
||||
void Awake()
|
||||
{
|
||||
recoilTarget = new SpringEulerAngle(damp, frequence);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
recoilTarget.Update(Time.deltaTime, Vector3.zero);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(recoilTarget.value), 0.75f); //这里使用一个较大的插值数字以实现枪口的迅速抬升
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
recoilTarget.value = new Vector3(Random.Range(-20, 0), Random.Range(-3, 3), 0); //这里做一个随机偏移来模拟后坐力。
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
11
Packages/Common~/Extensions/FPS/Recoil.cs.meta
Normal file
11
Packages/Common~/Extensions/FPS/Recoil.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cd4026f7e4457e41b9cb1843101fc90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
28
Packages/Common~/Extensions/FPS/Spring3.cs
Normal file
28
Packages/Common~/Extensions/FPS/Spring3.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit.FPS
|
||||
{
|
||||
public class Spring3
|
||||
{
|
||||
public Vector3 value = Vector2.zero;
|
||||
private Vector3 dampValue = Vector2.zero;
|
||||
private float damp = 1;
|
||||
private float frequence = 1;
|
||||
public void Clear()
|
||||
{
|
||||
value = Vector2.zero;
|
||||
dampValue = Vector2.zero;
|
||||
}
|
||||
public Spring3(float damp, float frequence)
|
||||
{
|
||||
this.damp = damp;
|
||||
this.frequence = frequence;
|
||||
}
|
||||
public void Update(float deltaTime, Vector3 target)
|
||||
{
|
||||
value -= dampValue * deltaTime * frequence;
|
||||
dampValue = Vector3.Lerp(dampValue, value - target, deltaTime * damp);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Extensions/FPS/Spring3.cs.meta
Normal file
11
Packages/Common~/Extensions/FPS/Spring3.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2460f020b90a9a49bd026d855835e65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Packages/Common~/Extensions/FPS/SpringEulerAngle.cs
Normal file
37
Packages/Common~/Extensions/FPS/SpringEulerAngle.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SpringEulerAngle
|
||||
{
|
||||
public float damp = 20;
|
||||
public float frequence = 15;
|
||||
[HideInInspector]
|
||||
public Vector3 value = Vector2.zero;
|
||||
Vector3 dampValue = Vector2.zero;
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
value = Vector2.zero;
|
||||
dampValue = Vector2.zero;
|
||||
}
|
||||
|
||||
public void Update(float deltaTime, Vector3 target)
|
||||
{
|
||||
value -= dampValue * deltaTime * frequence;
|
||||
dampValue = eulerLerp(dampValue, value - target, deltaTime * damp);
|
||||
}
|
||||
public static Vector3 eulerLerp(Vector3 left, Vector3 right, float t)
|
||||
{
|
||||
Vector3 ret;
|
||||
ret.x = Mathf.LerpAngle(left.x, right.x, t);
|
||||
ret.y = Mathf.LerpAngle(left.y, right.y, t);
|
||||
ret.z = Mathf.LerpAngle(left.z, right.z, t);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Extensions/FPS/SpringEulerAngle.cs.meta
Normal file
11
Packages/Common~/Extensions/FPS/SpringEulerAngle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38f88d6a22f4f074faec6cf7018cf92c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user