Optimize physical effects, optimize eye tracking, bug fix
This commit is contained in:
@@ -39,16 +39,14 @@ public class UmaContainer : MonoBehaviour
|
||||
public bool IsMini = false;
|
||||
public List<Texture2D> MiniHeadTextures = new List<Texture2D>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
HeadBone = (GameObject)Body.GetComponent<AssetHolder>()._assetTable.list.FindLast(a => a.Key == "head").Value;
|
||||
EyeHeight = 0.1f;
|
||||
TrackTarget = Camera.main.gameObject;
|
||||
}
|
||||
|
||||
public void MergeModel()
|
||||
{
|
||||
if (!Body) return;
|
||||
|
||||
HeadBone = (GameObject)Body.GetComponent<AssetHolder>()._assetTable.list.FindLast(a => a.Key == "head").Value;
|
||||
EyeHeight = 0.1f;
|
||||
TrackTarget = Camera.main.gameObject;
|
||||
|
||||
List<Transform> bodybones = new List<Transform>(Body.GetComponentInChildren<SkinnedMeshRenderer>().bones);
|
||||
List<Transform> emptyBones = new List<Transform>();
|
||||
emptyBones.Add(Body.GetComponentInChildren<SkinnedMeshRenderer>().rootBone.Find("Tail_Ctrl"));
|
||||
@@ -141,12 +139,12 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (TrackTarget)
|
||||
if (TrackTarget&&!isAnimatorControl)
|
||||
{
|
||||
var targetPosotion = TrackTarget.transform.position - new Vector3(0, EyeHeight, 0);
|
||||
var targetPosotion = TrackTarget.transform.position - HeadBone.transform.up*EyeHeight;
|
||||
var deltaPos = HeadBone.transform.InverseTransformPoint(targetPosotion);
|
||||
var deltaRotation = HeadBone.transform.InverseTransformDirection(deltaPos.normalized);
|
||||
var finalRotation = new Vector2(Mathf.Clamp(deltaRotation.x / 0.86f,-1,1), Mathf.Clamp(deltaRotation.y / 0.86f, -1, 1));//Limited to the angle of view
|
||||
var finalRotation = new Vector2(Mathf.Clamp(deltaRotation.x / 0.86f,-1,1), Mathf.Clamp(deltaRotation.y / 0.66f, -1, 1));//Limited to the angle of view
|
||||
FaceDrivenKeyTarget.SetEyeRange(finalRotation.x, finalRotation.y, finalRotation.x, -finalRotation.y);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
container.Slider.value = morph.weight;
|
||||
container.Slider.maxValue = 1;
|
||||
container.Slider.minValue = 0;
|
||||
container.Slider.onValueChanged.AddListener((a) => { target.ChangeMorphWeight(morph, a); });
|
||||
container.Slider.onValueChanged.AddListener((a) => {target.ChangeMorphWeight(morph, a);});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
container.Slider.value = emotion.Weight;
|
||||
container.Slider.maxValue = 1;
|
||||
container.Slider.minValue = 0;
|
||||
container.Slider.onValueChanged.AddListener((a) => { emotion.Weight = a; });
|
||||
container.Slider.onValueChanged.AddListener((a) => { target.ChangeEmotionWeight(emotion, a); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,14 +89,26 @@ namespace Gallop
|
||||
var bone = gameObjects.Find(a => { return a.name == spring._boneName; });
|
||||
if (bone)
|
||||
{
|
||||
bool isTail = gameObject.name.Contains("tail");//The tail needs less traction
|
||||
var dynamic = gameObject.AddComponent<DynamicBone>();
|
||||
dynamic.m_Root = bone;
|
||||
dynamic.m_UpdateMode = DynamicBone.UpdateMode.Normal;
|
||||
dynamic.m_Gravity = new Vector3(0, Mathf.Clamp01(-spring._gravity / 80000), 0);
|
||||
dynamic.m_Damping = 0.2f;
|
||||
dynamic.m_Stiffness = Mathf.Clamp01(spring._stiffnessForce / 900);
|
||||
dynamic.m_Elasticity = Mathf.Clamp01(spring._dragForce / 4000);
|
||||
dynamic.m_Gravity = new Vector3(0, Mathf.Clamp01(-30 / spring._gravity), 0);
|
||||
if (isTail)
|
||||
{
|
||||
dynamic.m_Damping = 0.1f;
|
||||
dynamic.m_Stiffness = Mathf.Clamp01(10 / spring._stiffnessForce);
|
||||
dynamic.m_Elasticity = Mathf.Clamp01(10 / spring._dragForce);
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic.m_Damping = 0.2f;
|
||||
dynamic.m_Stiffness = Mathf.Clamp01(40 / spring._stiffnessForce);
|
||||
dynamic.m_Elasticity = Mathf.Clamp01(40 / spring._dragForce);
|
||||
|
||||
}
|
||||
dynamic.m_Radius = spring._collisionRadius;
|
||||
|
||||
dynamic.SetupParticles();
|
||||
DynamicBones.Add(dynamic);
|
||||
|
||||
@@ -114,8 +126,18 @@ namespace Gallop
|
||||
if (tempParticle != null)
|
||||
{
|
||||
tempParticle.m_Damping = 0.2f;
|
||||
tempParticle.m_Stiffness = Mathf.Clamp01(Childcollision._stiffnessForce / 900);
|
||||
tempParticle.m_Elasticity = Mathf.Clamp01(Childcollision._dragForce / 4000);
|
||||
if (isTail)
|
||||
{
|
||||
tempParticle.m_Damping = 0.1f;
|
||||
tempParticle.m_Stiffness = Mathf.Clamp01(10 / spring._stiffnessForce);
|
||||
tempParticle.m_Elasticity = Mathf.Clamp01(10 / spring._dragForce);
|
||||
}
|
||||
else
|
||||
{
|
||||
tempParticle.m_Damping = 0.2f;
|
||||
tempParticle.m_Stiffness = Mathf.Clamp01(40 / spring._stiffnessForce);
|
||||
tempParticle.m_Elasticity = Mathf.Clamp01(40 / spring._dragForce);
|
||||
}
|
||||
tempParticle.m_Radius = Childcollision._collisionRadius;
|
||||
foreach (string collisionName in Childcollision._collisionNameList)
|
||||
{
|
||||
|
||||
@@ -241,6 +241,7 @@ namespace Gallop
|
||||
|
||||
public void ChangeMorphWeight(FacialMorph morph,float val)
|
||||
{
|
||||
Container.isAnimatorControl = false;
|
||||
morph.weight = val;
|
||||
ChangeMorph();
|
||||
}
|
||||
|
||||
@@ -67,6 +67,12 @@ public class FaceEmotionKeyTarget : ScriptableObject
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeEmotionWeight(FaceTypeData emotion, float val)
|
||||
{
|
||||
FaceDrivenKeyTarget.Container.isAnimatorControl = false;
|
||||
emotion.Weight = val;
|
||||
}
|
||||
|
||||
public void UpdateAllFacialKeyTargets()
|
||||
{
|
||||
if (FaceDrivenKeyTarget == null) return;
|
||||
|
||||
Reference in New Issue
Block a user