Fix head collider

This commit is contained in:
Jens Pitkänen 2020-08-10 19:04:28 +03:00
parent e516d15cb5
commit bfd45d114c
2 changed files with 9 additions and 6 deletions

View File

@ -1765,13 +1765,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7391558913556166741}
m_LocalRotation: {x: 0.16312791, y: 0, z: 0, w: 0.9866049}
m_LocalPosition: {x: 0, y: 1.86, z: 0.16}
m_LocalRotation: {x: -0.022665668, y: 0.9763826, z: 0.17216267, w: -0.1285432}
m_LocalPosition: {x: -0.0486503, y: 1.7423954, z: 0.09142446}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 7391558912774766616}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 18.777, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &7391558913556166743
BoxCollider:
m_ObjectHideFlags: 0
@ -1783,8 +1783,8 @@ BoxCollider:
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.4, y: 0.35, z: 0.4}
m_Center: {x: 0, y: 0, z: 0}
m_Size: {x: 0.5, y: 0.4, z: 0.5}
m_Center: {x: 0, y: 0.175, z: -0.05}
--- !u!54 &3448207716120070849
Rigidbody:
m_ObjectHideFlags: 0

View File

@ -28,6 +28,7 @@ namespace NeonTea.Quakeball.Animation {
private Transform BehindHand;
private Transform FrontHand;
private Transform Torso;
private Transform Head;
private float VisualYaw;
private float VisualPitch;
@ -54,7 +55,7 @@ namespace NeonTea.Quakeball.Animation {
}
Animator = Soldiers[(int)Model].GetComponent<Animator>();
Animator.gameObject.SetActive(true);
HeadCollider.parent = TransformUtil.FindChildWithName(Animator.transform, "HEAD");
Head = TransformUtil.FindChildWithName(Animator.transform, "HEAD");
Torso = TransformUtil.FindChildWithName(Animator.transform, "RIBS");
BehindHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.R");
FrontHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.L");
@ -97,6 +98,8 @@ namespace NeonTea.Quakeball.Animation {
transform.localEulerAngles = new Vector3(0, VisualYaw, 0);
Torso.localEulerAngles = new Vector3(VisualPitch, 0, 0);
HeadCollider.position = Head.position;
HeadCollider.eulerAngles = Head.eulerAngles;
if (GunGluedToHand) {
Vector3 GunOffset = GunHandle.position - Gun.position;