diff options
Diffstat (limited to 'JamHelper/Assets/JamUtils/FastIK/Scripts/Sample')
6 files changed, 113 insertions, 0 deletions
diff --git a/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleProcedualAnimation.cs b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleProcedualAnimation.cs new file mode 100644 index 0000000..01e38ff --- /dev/null +++ b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleProcedualAnimation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace DitzelGames.FastIK +{ + class SampleProcedualAnimation : MonoBehaviour + { + public Transform[] FootTarget; + public Transform LookTarget; + public Transform HandTarget; + public Transform HandPole; + public Transform Step; + public Transform Attraction; + + public void LateUpdate() + { + //move step & attraction + Step.Translate(Vector3.forward * Time.deltaTime * 0.7f); + if (Step.position.z > 1f) + Step.position = Step.position + Vector3.forward * -2f; + Attraction.Translate(Vector3.forward * Time.deltaTime * 0.5f); + if (Attraction.position.z > 1f) + Attraction.position = Attraction.position + Vector3.forward * -2f; + + //footsteps + for(int i = 0; i < FootTarget.Length; i++) + { + var foot = FootTarget[i]; + var ray = new Ray(foot.transform.position + Vector3.up * 0.5f, Vector3.down); + var hitInfo = new RaycastHit(); + if(Physics.SphereCast(ray, 0.05f, out hitInfo, 0.50f)) + foot.position = hitInfo.point + Vector3.up * 0.05f; + } + + //hand and look + var normDist = Mathf.Clamp((Vector3.Distance(LookTarget.position, Attraction.position) - 0.3f) / 1f, 0, 1); + HandTarget.rotation = Quaternion.Lerp(Quaternion.Euler(90, 0, 0), HandTarget.rotation, normDist); + HandTarget.position = Vector3.Lerp(Attraction.position, HandTarget.position, normDist); + HandPole.position = Vector3.Lerp(HandTarget.position + Vector3.down * 2, HandTarget.position + Vector3.forward * 2f, normDist); + LookTarget.position = Vector3.Lerp(Attraction.position, LookTarget.position, normDist); + + + } + + } +} diff --git a/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleProcedualAnimation.cs.meta b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleProcedualAnimation.cs.meta new file mode 100644 index 0000000..7f3ffb6 --- /dev/null +++ b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleProcedualAnimation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1c9cd2c593f693345ad26b97d5a0d43f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 100 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleRotator.cs b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleRotator.cs new file mode 100644 index 0000000..62f201d --- /dev/null +++ b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleRotator.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace DitzelGames.FastIK +{ + public class SampleRotator : MonoBehaviour + { + + void Update() + { + //just rotate the object + transform.Rotate(0, Time.deltaTime * 90, 0); + } + } +} diff --git a/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleRotator.cs.meta b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleRotator.cs.meta new file mode 100644 index 0000000..5fd4b94 --- /dev/null +++ b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleRotator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e9a7a99d0dda4cf438c3fd3db6627c08 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleSinMover.cs b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleSinMover.cs new file mode 100644 index 0000000..0607082 --- /dev/null +++ b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleSinMover.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +namespace DitzelGames.FastIK +{ + public class SampleSinMover : MonoBehaviour + { + public Vector3 Dir; + public Vector3 Start; + + private void Awake() + { + Start = transform.position; + } + + void Update() + { + //just move the object from a to b and back + transform.position = Start + Dir * Mathf.Sin(Time.timeSinceLevelLoad); + } + } +} diff --git a/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleSinMover.cs.meta b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleSinMover.cs.meta new file mode 100644 index 0000000..9095f54 --- /dev/null +++ b/JamHelper/Assets/JamUtils/FastIK/Scripts/Sample/SampleSinMover.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf9a667200f2ae8459b397bc03e59350 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |