/// <summary> /// /// </summary> protected override void Awake() { base.Awake(); m_Transform = transform; bl_PhotonCallbacks.PlayerEnteredRoom += OnPhotonPlayerConnected; bl_AIMananger.OnBotStatUpdate += OnBotStatUpdate; Agent = this.GetComponent <NavMeshAgent>(); AIAnim = GetComponentInChildren <bl_AIAnimation>(); AIHealth = GetComponent <bl_AIShooterHealth>(); AIWeapon = GetComponent <bl_AIShooterWeapon>(); defaultSpeed = Agent.speed; Anim = GetComponentInChildren <Animator>(); ObstacleBetweenTarget = false; CoverManager = FindObjectOfType <bl_AICovertPointManager>(); AIManager = CoverManager.GetComponent <bl_AIMananger>(); TimeManager = FindObjectOfType <bl_RoundTime>(); DrawName = GetComponent <bl_DrawName>(); m_GameMode = GetGameMode; }
/// <summary> /// /// </summary> void Awake() { Agent = GetComponent <bl_AIShooterAgent>(); AIManager = FindObjectOfType <bl_AIMananger>(); AIAnim = GetComponentInChildren <bl_AIAnimation>(); }
void ReplaceBotModel() { if (ModelPrefab == null) { return; } GameObject model = ModelPrefab; if (PrefabUtility.GetPrefabParent(ModelPrefab) == null && PrefabUtility.GetPrefabObject(ModelPrefab) != null) { model = PrefabUtility.InstantiatePrefab(ModelPrefab) as GameObject; #if UNITY_2018_3_OR_NEWER PrefabUtility.UnpackPrefabInstance(model, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction); #endif } model.name += " [NEW]"; GameObject botPrefab = PrefabUtility.InstantiatePrefab(bl_GameData.Instance.BotTeam1) as GameObject; #if UNITY_2018_3_OR_NEWER PrefabUtility.UnpackPrefabInstance(botPrefab, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction); #endif botPrefab.name = "AISoldier [NEW]"; bl_AIAnimation oldModel = botPrefab.GetComponentInChildren <bl_AIAnimation>(); oldModel.name += " [OLD]"; Animator modelAnimator = model.GetComponent <Animator>(); modelAnimator.applyRootMotion = false; modelAnimator.runtimeAnimatorController = oldModel.GetComponent <Animator>().runtimeAnimatorController; if (!AutoRagdoller.Build(modelAnimator)) { Debug.LogError("Could not build a ragdoll for this model"); return; } botPrefab.GetComponent <bl_AIShooterAgent>().AimTarget = modelAnimator.GetBoneTransform(HumanBodyBones.Spine); model.transform.parent = oldModel.transform.parent; model.transform.localPosition = oldModel.transform.localPosition; model.transform.localRotation = oldModel.transform.localRotation; bl_AIAnimation aia = model.AddComponent <bl_AIAnimation>(); aia.mRigidBody.AddRange(model.transform.GetComponentsInChildren <Rigidbody>()); Collider[] allColliders = model.transform.GetComponentsInChildren <Collider>(); for (int i = 0; i < allColliders.Length; i++) { allColliders[i].gameObject.layer = LayerMask.NameToLayer("Player"); allColliders[i].gameObject.tag = "AI"; bl_AIHitBox hbox = allColliders[i].gameObject.AddComponent <bl_AIHitBox>(); hbox.m_Collider = allColliders[i]; hbox.AI = botPrefab.GetComponent <bl_AIShooterHealth>(); hbox.isHead = allColliders[i].name.ToLower().Contains("head"); aia.HitBoxes.Add(hbox); } Transform weaponRoot = botPrefab.GetComponent <bl_AIShooterWeapon>().m_AIWeapons[0].WeaponObject.transform.parent; Vector3 wrp = weaponRoot.localPosition; Quaternion wrr = weaponRoot.localRotation; weaponRoot.parent = modelAnimator.GetBoneTransform(HumanBodyBones.RightHand); weaponRoot.localRotation = wrr; weaponRoot.localPosition = wrp; DestroyImmediate(oldModel.gameObject); var view = (SceneView)SceneView.sceneViews[0]; view.LookAt(botPrefab.transform.position); EditorGUIUtility.PingObject(botPrefab); Selection.activeTransform = botPrefab.transform; }