IEnumerator Start() { if (fireSound) { if (!audioSource) { audioSource = GetComponent <AudioSource>(); } } if (!audioSource) { audioSource = gameObject.AddComponent <AudioSource>(); audioSource.spatialBlend = 1f; } yield return(new WaitForEndOfFrame()); playerTr = WheelDriveCustom.s_player.transform; //if (fireAtStart) //{ // yield return new WaitForSeconds(2f); // FireRandomDelayLoop(); //} ConstraintSource cs = new ConstraintSource { sourceTransform = playerTr, weight = 1 }; lookAtConstraint.RemoveSource(0); lookAtConstraint.AddSource(cs); }
//Look Constrait------------------------------------------------------------- //Clear Sourcers public static void ClearSources(this LookAtConstraint posCons) { int length = posCons.sourceCount; for (int i = 0; i < length; i++) { posCons.RemoveSource(0); } }