private void Update() { if (Loader.HasLoaded) { if (!loadedModelOnStartup) { _player.OnSpawn(); // load model on startup Debug.Log("Loading pedestrian model after startup."); Load(m_startingPedId); // and play animation PlayAnim(AnimGroup.WalkCycle, AnimIndex.Idle, PlayMode.StopAll); loadedModelOnStartup = true; } } }
private void Update() { #if UNITY_EDITOR if (!EditorApplication.isPlaying) { return; } #endif if (Loader.HasLoaded) { if (!loadedModelOnStartup) { _player.OnSpawn(); // load model on startup Debug.Log("Loading pedestrian model after startup."); Load(PedestrianId); // and play animation PlayAnim(AnimGroup.WalkCycle, AnimIndex.Idle, PlayMode.StopAll); loadedModelOnStartup = true; } } // update transform of weapon if (weapon != null && m_rightFinger != null && m_leftFinger != null) { weapon.transform.position = m_rightFinger.transform.position; Vector3 dir = (m_leftFinger.transform.position - m_rightFinger.transform.position).normalized; Quaternion q = Quaternion.LookRotation(dir, transform.up); Vector3 upNow = q * Vector3.up; dir = Quaternion.AngleAxis(-90, upNow) * dir; weapon.transform.rotation = Quaternion.LookRotation(dir, transform.up); } }