//Setup hinges and springs void Start() { leftLegHinge = LeftLegBone.GetComponent <HingeJoint>(); leftLegBoneSpring = leftLegHinge.spring; rightLegHinge = RightLegBone.GetComponent <HingeJoint>(); rightLegBoneSpring = rightLegHinge.spring; rightElbowHinge = RightElbowBone.GetComponent <HingeJoint>(); rightElbowBoneSpring = rightElbowHinge.spring; leftElbowHinge = LeftElbowBone.GetComponent <HingeJoint>(); leftElbowBoneSpring = leftElbowHinge.spring; chestBoneHinge = ChestBone.GetComponent <HingeJoint>(); chestBoneSpring = chestBoneHinge.spring; headBoneHinge = HeadBone.GetComponent <HingeJoint>(); headBoneSpring = headBoneHinge.spring; }
public void SetImportDefault() { transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; Animation model = Animation; if (model.GetComponentsInChildren <SkinnedMeshRenderer>().Length > 1) { Debug.LogError("SkinnedMesh count error"); } m_AnimationStates = null; CheckBones(); model.transform.localRotation = rotationCharacter; model.GetComponent <Animation>().clip = null; model.GetComponent <Animation>().playAutomatically = false; model.GetComponent <Animation>().cullingType = AnimationCullingType.AlwaysAnimate; m_DefaultStateName = "battleidle"; Transform bip_node = FindTransform(model.transform, "Bip"); AnimationState idle_state = Animation["idle"]; if (idle_state != null && HeadBone != null) { idle_state.enabled = true; idle_state.time = 0f; idle_state.weight = 1f; Animation.Sample(); idle_state.enabled = false; IdleRotation = 90f - GetRotation(HeadBone.transform, transform).eulerAngles.y; } AnimationState default_state = Animation[m_DefaultStateName]; if (default_state != null) { default_state.enabled = true; default_state.time = 0f; default_state.weight = 1f; Animation.Sample(); default_state.enabled = false; } { BoxCollider temp_col = GetComponent <BoxCollider>(); if (temp_col != null) { DestroyImmediate(temp_col, true); } CapsuleCollider collider = GetComponent <CapsuleCollider>(); if (collider == null) { collider = gameObject.AddComponent <CapsuleCollider>(); collider.center = new Vector3(0f, 4f, 0f); collider.radius = 3f; collider.height = 10f; } } if (bip_node != null) { BoxCollider temp_col = bip_node.GetComponent <BoxCollider>(); if (temp_col != null) { DestroyImmediate(temp_col, true); } SphereCollider collider = bip_node.GetComponent <SphereCollider>(); if (collider != null) { DestroyImmediate(collider, true); } } if (HeadBone != null) { SphereCollider collider = HeadBone.GetComponent <SphereCollider>(); if (collider == null) { collider = HeadBone.gameObject.AddComponent <SphereCollider>(); } collider.center = new Vector3(-1.5f, 0f, 0f); collider.radius = 3; } //RootBone.localRotation = Quaternion.Euler(-90f, 180f, 0f); CoreUtility.SetRecursiveLayer(gameObject, "Character"); RefreshMove(true); RefreshFx(true); string prefab_path = "Assets/Character/" + gameObject.name + ".prefab"; CharacterAnimation prefab = AssetDatabase.LoadAssetAtPath(prefab_path, typeof(CharacterAnimation)) as CharacterAnimation; if (prefab == null) { PrefabUtility.CreatePrefab(prefab_path, gameObject, ReplacePrefabOptions.ConnectToPrefab); } else { PrefabUtility.ReplacePrefab(gameObject, prefab, ReplacePrefabOptions.ConnectToPrefab); } }
void Start() { headBoneRigidbody = HeadBone.GetComponent <Rigidbody>(); }