// Use this for initialization private void Start() { actor_parameter_ = GetComponent <ActorParameter>(); // 初期ステートの生成 switch (actor_type_) { case ActorType.kAnonymous: actor_state_ = gameObject.AddComponent <NpcDemoState>(); break; case ActorType.kGolem: actor_state_ = gameObject.AddComponent <NpcDemoState>(); break; case ActorType.kCarbuncle: actor_state_ = gameObject.AddComponent <NpcDemoState>(); break; case ActorType.kSoul: { var soul_state = gameObject.AddComponent <SoulState>(); soul_state.SetSoulAmount(SoulState.kMaxSoulAmount); actor_state_ = soul_state; break; } default: break; } // Minimapでの表示 if (actor_type_ != ActorType.kSoul && MinimapSystem.Instance) { MinimapSystem.Instance.RegisterActor(this); } actor_state_.Init(this); }
// 移動処理 private void Move(ActorController actor_controller) { float direction_magnitude = direction_.magnitude; if (animator_) { animator_.SetFloat("movement", direction_magnitude); } if (direction_magnitude == 0.0f) { return; } ActorParameter parameter = actor_controller.GetActorParameter(); nav_mesh_agent_.Move(direction_ * parameter.MoveSpeed * speed_rate_ * Time.deltaTime); // 物理演算の時の回転を切ったのため直接にtransformで回転する direction_ = transform.InverseTransformDirection(direction_); var turn_amount = Mathf.Atan2(direction_.x, direction_.z); transform.Rotate(0f, turn_amount * parameter.TurnSpeed * Time.deltaTime, 0f); }