initial upload
This commit is contained in:
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Boxing.unity
(Stored with Git LFS)
Normal file
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Boxing.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 723636789bb96481ba1f2aad8b8837e9
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Controller.unity
(Stored with Git LFS)
Normal file
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Controller.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f097b72f6aff88c4c8120011f31f3891
|
||||
timeCreated: 1512476571
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Swing.unity
(Stored with Git LFS)
Normal file
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Swing.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfa34265300d7414bbf930eaa6bfb70e
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Weapon.unity
(Stored with Git LFS)
Normal file
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Aim Weapon.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 912d260eace234ee1b283ba7f07dd3d7
|
||||
timeCreated: 1433755866
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/AimIK Pole.unity
(Stored with Git LFS)
Normal file
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/AimIK Pole.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cb81a7ab90c447829d4d26f8ca89245
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2af3d7e2f50d2458c893c63a1ab835
|
||||
folderAsset: yes
|
||||
timeCreated: 1434626795
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using RootMotion.FinalIK;
|
||||
|
||||
namespace RootMotion.Demos {
|
||||
|
||||
/// <summary>
|
||||
/// Boxing with Aim IK.
|
||||
/// Changing character facing direction with Aim IK to follow the target.
|
||||
/// </summary>
|
||||
public class AimBoxing : MonoBehaviour {
|
||||
|
||||
public AimIK aimIK; // Reference to the AimIK component
|
||||
public Transform pin; // The hitting point as in the animation
|
||||
|
||||
void LateUpdate() {
|
||||
// Rotate the aim Transform to look at the point, where the fist hits its target in the animation.
|
||||
// This will set the animated hit direction as the default starting point for Aim IK (direction for which Aim IK has to do nothing).
|
||||
aimIK.solver.transform.LookAt(pin.position);
|
||||
|
||||
// Set myself as IK target
|
||||
aimIK.solver.IKPosition = transform.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66452eca044e1420e9e9bd2945a6bad7
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using RootMotion.FinalIK;
|
||||
|
||||
namespace RootMotion.Demos {
|
||||
|
||||
public class AimSwing : MonoBehaviour {
|
||||
|
||||
public AimIK ik;
|
||||
[Tooltip("The direction in which the weapon is aimed in animation (in character space). Tweak this value to adjust the aiming.")] public Vector3 animatedAimDirection = Vector3.forward;
|
||||
|
||||
void LateUpdate () {
|
||||
ik.solver.axis = ik.solver.transform.InverseTransformVector(ik.transform.rotation * animatedAimDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ccef35d59367884b8f5847c819438b4
|
||||
timeCreated: 1494334657
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using RootMotion.FinalIK;
|
||||
|
||||
namespace RootMotion.Demos
|
||||
{
|
||||
// Using LimbIK on the left arm to put the left hand back to where it was relative to the right hand before solving AimIK on the spine and right arm bones.
|
||||
public class SecondHandOnGun : MonoBehaviour
|
||||
{
|
||||
public AimIK aim;
|
||||
public LimbIK leftArmIK;
|
||||
public Transform leftHand, rightHand;
|
||||
public GrounderFBBIK grounder;
|
||||
|
||||
public Vector3 leftHandPositionOffset;
|
||||
public Vector3 leftHandRotationOffset;
|
||||
|
||||
private Vector3 leftHandPosRelToRight;
|
||||
private Quaternion leftHandRotRelToRight;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Disable the IK components to take control over the updating of their solvers
|
||||
aim.enabled = false;
|
||||
leftArmIK.enabled = false;
|
||||
if (grounder != null) grounder.ik.enabled = false;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
// Store the position and rotation of the left hand relative to the right as animated
|
||||
leftHandPosRelToRight = rightHand.InverseTransformPoint(leftHand.position);
|
||||
leftHandRotRelToRight = Quaternion.Inverse(rightHand.rotation) * leftHand.rotation;
|
||||
|
||||
// Update FBBIK for grounding
|
||||
if (grounder != null) grounder.ik.solver.Update();
|
||||
|
||||
// Update AimIK
|
||||
aim.solver.Update();
|
||||
|
||||
// AimIK has moved the right arm, so the hand hand needs to be put back to how it was relative to the right hand (the inverse of the above)
|
||||
leftArmIK.solver.IKPosition = rightHand.TransformPoint(leftHandPosRelToRight + leftHandPositionOffset);
|
||||
leftArmIK.solver.IKRotation = rightHand.rotation * Quaternion.Euler(leftHandRotationOffset) * leftHandRotRelToRight;
|
||||
|
||||
// Update Left arm IK (we don't want another FBBIK pass, LimbIK is much faster)
|
||||
leftArmIK.solver.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 197630ec716e8f54d8547033d33eb8ad
|
||||
timeCreated: 1535372901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,93 @@
|
||||
using RootMotion.Demos;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using RootMotion.FinalIK;
|
||||
|
||||
namespace RootMotion.Demos {
|
||||
|
||||
// Demonstrating 360-degree aiming system built with 6 static aiming poses and AimIK.
|
||||
public class SimpleAimingSystem : MonoBehaviour {
|
||||
|
||||
[Tooltip("AimPoser is a tool that returns an animation name based on direction.")]
|
||||
public AimPoser aimPoser;
|
||||
|
||||
[Tooltip("Reference to the AimIK component.")]
|
||||
public AimIK aim;
|
||||
|
||||
[Tooltip("Reference to the LookAt component (only used for the head in this instance).")]
|
||||
public LookAtIK lookAt;
|
||||
|
||||
[Tooltip("Reference to the Animator component.")]
|
||||
public Animator animator;
|
||||
|
||||
[Tooltip("Time of cross-fading from pose to pose.")]
|
||||
public float crossfadeTime = 0.2f;
|
||||
|
||||
[Tooltip("Will keep the aim target at a distance.")]
|
||||
public float minAimDistance = 0.5f;
|
||||
|
||||
private AimPoser.Pose aimPose, lastPose;
|
||||
|
||||
void Start() {
|
||||
// Disable IK components to manage their updating order
|
||||
aim.enabled = false;
|
||||
lookAt.enabled = false;
|
||||
}
|
||||
|
||||
// LateUpdate is called once per frame
|
||||
void LateUpdate () {
|
||||
// Switch aim poses (Legacy animation)
|
||||
Pose();
|
||||
|
||||
// Update IK solvers
|
||||
aim.solver.Update();
|
||||
if (lookAt != null) lookAt.solver.Update();
|
||||
}
|
||||
|
||||
private void Pose() {
|
||||
// Make sure aiming target is not too close (might make the solver instable when the target is closer to the first bone than the last bone is).
|
||||
LimitAimTarget();
|
||||
|
||||
// Get the aiming direction
|
||||
Vector3 direction = (aim.solver.IKPosition - aim.solver.bones[0].transform.position);
|
||||
// Getting the direction relative to the root transform
|
||||
Vector3 localDirection = transform.InverseTransformDirection(direction);
|
||||
|
||||
// Get the Pose from AimPoser
|
||||
aimPose = aimPoser.GetPose(localDirection);
|
||||
|
||||
// If the Pose has changed
|
||||
if (aimPose != lastPose) {
|
||||
// Increase the angle buffer of the pose so we won't switch back too soon if the direction changes a bit
|
||||
aimPoser.SetPoseActive(aimPose);
|
||||
|
||||
// Store the pose so we know if it changes
|
||||
lastPose = aimPose;
|
||||
}
|
||||
|
||||
// Direct blending
|
||||
foreach (AimPoser.Pose pose in aimPoser.poses) {
|
||||
if (pose == aimPose) {
|
||||
DirectCrossFade(pose.name, 1f);
|
||||
} else {
|
||||
DirectCrossFade(pose.name, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure aiming target is not too close (might make the solver instable when the target is closer to the first bone than the last bone is).
|
||||
void LimitAimTarget() {
|
||||
Vector3 aimFrom = aim.solver.bones[0].transform.position;
|
||||
Vector3 direction = (aim.solver.IKPosition - aimFrom);
|
||||
direction = direction.normalized * Mathf.Max(direction.magnitude, minAimDistance);
|
||||
|
||||
aim.solver.IKPosition = aimFrom + direction;
|
||||
}
|
||||
|
||||
// Uses Mecanim's Direct blend trees for cross-fading
|
||||
private void DirectCrossFade(string state, float target) {
|
||||
float f = Mathf.MoveTowards(animator.GetFloat(state), target, Time.deltaTime * (1f / crossfadeTime));
|
||||
animator.SetFloat(state, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80dd97a5e7b214f88860e8a63328b1e3
|
||||
timeCreated: 1433754666
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using RootMotion.FinalIK;
|
||||
|
||||
namespace RootMotion.Demos {
|
||||
|
||||
/// <summary>
|
||||
/// Raycasting to the ground to redirect upper-body animation based on ground topography.
|
||||
/// </summary>
|
||||
public class TerrainOffset : MonoBehaviour {
|
||||
|
||||
public AimIK aimIK; // Reference to the AimIK component
|
||||
public Vector3 raycastOffset = new Vector3(0f, 2f, 1.5f); // Offset from the character, in local space, to raycast from
|
||||
public LayerMask raycastLayers; // The layers we want to raycast at
|
||||
public float min = -2f, max = 2f; // Min and max for the offset
|
||||
public float lerpSpeed = 10f; // The speed of lerping the IKPosition to make things nice and smooth
|
||||
|
||||
private RaycastHit hit;
|
||||
private Vector3 offset;
|
||||
|
||||
void LateUpdate() {
|
||||
// Find the raycastOffset in world space
|
||||
Vector3 worldOffset = transform.rotation * raycastOffset;
|
||||
|
||||
// Find how much higher is the ground at worldOffset relative to the character position.
|
||||
Vector3 realOffset = GetGroundHeightOffset(transform.position + worldOffset);
|
||||
|
||||
// Smoothly lerp the offset value so it would not jump on sudden raycast changes
|
||||
offset = Vector3.Lerp(offset, realOffset, Time.deltaTime * lerpSpeed);
|
||||
|
||||
// The default offset point at the character's height
|
||||
Vector3 zeroOffsetPosition = transform.position + new Vector3(worldOffset.x, 0f, worldOffset.z);
|
||||
|
||||
// Make the Aim Transform look at the default offset point (So when we are on planar ground there will be nothing for Aim IK to do)
|
||||
aimIK.solver.transform.LookAt(zeroOffsetPosition);
|
||||
|
||||
// Make Aim IK bend the spine by the offset.
|
||||
aimIK.solver.IKPosition = zeroOffsetPosition + offset;
|
||||
}
|
||||
|
||||
private Vector3 GetGroundHeightOffset(Vector3 worldPosition) {
|
||||
// Visualize the raycast
|
||||
Debug.DrawRay(worldPosition, Vector3.down * raycastOffset.y * 2f, Color.green);
|
||||
|
||||
// Raycast to find how much higher is the ground at worldPosition relative to the character.
|
||||
if (Physics.Raycast(worldPosition, Vector3.down, out hit, raycastOffset.y * 2f)) {
|
||||
return Mathf.Clamp(hit.point.y - transform.position.y, min, max) * Vector3.up;
|
||||
}
|
||||
|
||||
// Raycast found nothing so return zero
|
||||
return Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7c5ddaa57a724f7baa46a4196fd27ee
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Second Hand On Gun.unity
(Stored with Git LFS)
Normal file
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Second Hand On Gun.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76a7b3578da45e14fbb46967d1abd801
|
||||
timeCreated: 1535372912
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Terrain Offset.unity
(Stored with Git LFS)
Normal file
BIN
Unity-Master/Assets/Plugins/RootMotion/FinalIK/_DEMOS/Aim IK/Terrain Offset.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 625128834590c457595556a63cd0d2fc
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user