/// <summary> /// Actor 出生 /// </summary> /// <param name="point"></param> /// <param name="actorArt"></param> protected virtual void Born(LevelPoint point, string actorArt) { // 创建角色 GameObject prefab = LevelAsset.GetGameObject(actorArt); var actorGo = GameObject.Instantiate <GameObject>(prefab); actorGo.transform.parent = transform; actorGameObject = actorGo.GetComponent <ActorGameObject>(); // 组件获取 m_animator = actorGameObject.GetComponent <Animator>(); m_rigidbody = actorGameObject.GetComponent <Rigidbody>(); m_navMeshAgent = actorGameObject.GetComponent <NavMeshAgent>(); // 基础设置 actorGameObject.actor = this; actorGameObject.transform.position = point.position; actorGameObject.transform.localEulerAngles = point.rotationAngle; // 寻路设置 m_navMeshAgent.speed = attribute.GetAttribute(ActorAttributeType.MoveSpeed); m_moveVt = Vector3.zero; m_dirVt = actorGameObject.transform.forward; }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { m_actorGamObject = animator.gameObject.GetComponent <ActorGameObject>(); m_actor = m_actorGamObject.actor; }