This commit is contained in:
CortexCore
2023-08-27 02:58:19 +08:00
parent 45913c6b3e
commit 4fadd3a530
322 changed files with 95590 additions and 109406 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit.Physics
{
[Serializable]
public class JointConfigure
{
public Transform animate;
public ConfigurableJoint joint;
public Quaternion InitialRotation { get; set; }
}
public class PhysicsBasedAnimation : MonoBehaviour
{
[Range(0, 1)] public float Blend;
[SerializeField] private JointConfigure[] jointConfigures;
[SerializeField] private float positionSpring;
[SerializeField] private float positionDamper;
[SerializeField] private float maximumForce;
private void Start()
{
foreach (var x in jointConfigures)
{
x.InitialRotation=x.animate.localRotation;
}
}
private void FixedUpdate()
{
//var spring = Mathf.Lerp(Blend,0,angularSprint);
var drive = new JointDrive
{
positionDamper = positionDamper,
positionSpring = positionSpring,
maximumForce = maximumForce,
};
foreach (var jointConfigure in jointConfigures)
{
jointConfigure.joint.angularXDrive = drive;
jointConfigure.joint.angularYZDrive = drive;
jointConfigure.joint.targetRotation = Quaternion.Inverse(jointConfigure.animate.localRotation) *
jointConfigure.InitialRotation;
}
}
}
}