Skip to main content

How to change Changing sound pitch value according toin sync with airplane propeller rotation speed?

It's like making theI'm trying to synchronize a rotating propeller with a engine sound by changing the sound's pitch sound engine starting effect.

I have some airplane with a propeller and a script attached to the propeller making thean airplane's propeller start spinning when runningwhich, after the game starts, causes it to gradually increase rotation speed from slow to max speedmaximum.

 using System.Collections;  using System.Collections.Generic;  using UnityEngine;    public class Spin : MonoBehaviour  {   public float RotationSpeed = 1;     // Start is called before the first frame update   void Start()   {     }     // Update is called once per frame   void Update()   {   transform.Rotate(0, 0, RotationSpeed, Space.Self);     if (RotationSpeed < 10)   {   RotationSpeed += 1f * Time.deltaTime;   }   }  } 

onOn an empty gameobject iI added audio sourcean AudioSource and dragged to it a mp3made its AudioClip an .mp3 sound effect of propeller and also attached to the empty gameobject a script and dragged to the script the propeller object with the Spin. To this gameobject I attached this script  :

and a screenshot of the empty gameobject with the audio source AudioSource component:

The pitch in the audio source by default startstarts at value 1 and should be changed between the values of -3 and 3. The rotation speed in the Spin script is in other units.

what iThe behavior I want to do is when i'm running the game and: as the propeller startstarts rotating slowly and increases to max speed that, the audio source pitch automatic will automatically change it'sits value according toin sync with the propeller rotation speed so the pitch sound and the propeller rotation will be sync.

TheHowever, the script AudioExample as it is now is making the pitch value to be much over thewell exceed 3 value over, in fact it goes up to 10. The calculation in the AudioExample script is wrong and i'mI'm not sure how to docorrect it  :

 _audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; 

How to change pitch value according to airplane propeller rotation speed?

It's like making the propeller with the pitch sound engine starting effect.

I have some airplane with a propeller and a script attached to the propeller making the propeller start spinning when running the game from slow to max speed.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spin : MonoBehaviour { public float RotationSpeed = 1; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.Rotate(0, 0, RotationSpeed, Space.Self); if (RotationSpeed < 10) { RotationSpeed += 1f * Time.deltaTime; } } } 

on empty gameobject i added audio source and dragged to it a mp3 sound effect of propeller and also attached to the empty gameobject a script and dragged to the script the propeller object with the Spin script  :

and a screenshot of the empty gameobject with the audio source :

The pitch in the audio source by default start at value 1 and be changed between the values -3 and 3. The rotation speed in the Spin script is in other units.

what i want to do is when i'm running the game and the propeller start rotating slowly to max speed that the pitch automatic will change it's value according to the propeller rotation speed so the pitch sound and the propeller rotation will be sync.

The script AudioExample as it is now making the pitch value to be much over the 3 value over 10. The calculation in the AudioExample script is wrong and i'm not sure how to do it  :

_audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; 

Changing sound pitch in sync with airplane propeller rotation speed

I'm trying to synchronize a rotating propeller with a engine sound by changing the sound's pitch.

I have a script attached to an airplane's propeller which, after the game starts, causes it to gradually increase rotation speed from slow to maximum.

 using System.Collections;  using System.Collections.Generic;  using UnityEngine;    public class Spin : MonoBehaviour  {   public float RotationSpeed = 1;     // Start is called before the first frame update   void Start()   {     }     // Update is called once per frame   void Update()   {   transform.Rotate(0, 0, RotationSpeed, Space.Self);     if (RotationSpeed < 10)   {   RotationSpeed += 1f * Time.deltaTime;   }   }  } 

On an empty gameobject I added an AudioSource and made its AudioClip an .mp3 sound effect of a propeller. To this gameobject I attached this script:

and a screenshot of the gameobject with the AudioSource component:

The pitch in the audio source by default starts at value 1 and should be changed between the values of -3 and 3. The rotation speed in the Spin script is in other units.

The behavior I want is: as the propeller starts rotating slowly and increases to max speed, the audio source pitch will automatically change its value in sync with the propeller rotation speed.

However, the script AudioExample as it is now is making the pitch value to well exceed 3, in fact it goes up to 10. The calculation in the AudioExample script is wrong and I'm not sure how to correct it:

 _audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; 
added 79 characters in body
Source Link
Daniel Lip
  • 1.8k
  • 4
  • 40
  • 81

It's like making the propeller with the pitch sound engine starting effect.

I have some airplane with a propeller and a script attached to the propeller making the propeller start spinning when running the game from slow to max speed.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spin : MonoBehaviour { public float RotationSpeed = 1; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.Rotate(0, 0, RotationSpeed, Space.Self); if (RotationSpeed < 10) { RotationSpeed += 1f * Time.deltaTime; } } } 

on empty gameobject i added audio source and dragged to it a mp3 sound effect of propeller and also attached to the empty gameobject a script and dragged to the script the propeller object with the Spin script :

using System.Collections; using System.Collections.Generic; using UnityEngine; public class AudioExample : MonoBehaviour { public int startingPitch = 4; public int decreaseAmount = 5; public Spin spin; private AudioSource _audioSource; void Start() { _audioSource = GetComponent<AudioSource>(); _audioSource.pitch = startingPitch; } void Update() { if (_audioSource.pitch > 0) { _audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; } } } 

Screenshot of the propeller object :

propeller

and a screenshot of the empty gameobject with the audio source :

empty gameobject

The pitch in the audio source by default start at value 1 and be changed between the values -3 and 3. The rotation speed in the Spin script is in other units.

what i want to do is when i'm running the game and the propeller start rotating slowly to max speed that the pitch automatic will change it's value according to the propeller rotation speed so the pitch sound and the propeller rotation will be sync.

The script AudioExample as it is now making the pitch value to be much over the 3 value over 10. The calculation in the AudioExample script is wrong and i'm not sure how to do it :

_audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; 

I have some airplane with a propeller and a script attached to the propeller making the propeller start spinning when running the game from slow to max speed.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spin : MonoBehaviour { public float RotationSpeed = 1; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.Rotate(0, 0, RotationSpeed, Space.Self); if (RotationSpeed < 10) { RotationSpeed += 1f * Time.deltaTime; } } } 

on empty gameobject i added audio source and dragged to it a mp3 sound effect of propeller and also attached to the empty gameobject a script and dragged to the script the propeller object with the Spin script :

using System.Collections; using System.Collections.Generic; using UnityEngine; public class AudioExample : MonoBehaviour { public int startingPitch = 4; public int decreaseAmount = 5; public Spin spin; private AudioSource _audioSource; void Start() { _audioSource = GetComponent<AudioSource>(); _audioSource.pitch = startingPitch; } void Update() { if (_audioSource.pitch > 0) { _audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; } } } 

Screenshot of the propeller object :

propeller

and a screenshot of the empty gameobject with the audio source :

empty gameobject

The pitch in the audio source by default start at value 1 and be changed between the values -3 and 3. The rotation speed in the Spin script is in other units.

what i want to do is when i'm running the game and the propeller start rotating slowly to max speed that the pitch automatic will change it's value according to the propeller rotation speed so the pitch sound and the propeller rotation will be sync.

The script AudioExample as it is now making the pitch value to be much over the 3 value over 10. The calculation in the AudioExample script is wrong and i'm not sure how to do it :

_audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; 

It's like making the propeller with the pitch sound engine starting effect.

I have some airplane with a propeller and a script attached to the propeller making the propeller start spinning when running the game from slow to max speed.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spin : MonoBehaviour { public float RotationSpeed = 1; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.Rotate(0, 0, RotationSpeed, Space.Self); if (RotationSpeed < 10) { RotationSpeed += 1f * Time.deltaTime; } } } 

on empty gameobject i added audio source and dragged to it a mp3 sound effect of propeller and also attached to the empty gameobject a script and dragged to the script the propeller object with the Spin script :

using System.Collections; using System.Collections.Generic; using UnityEngine; public class AudioExample : MonoBehaviour { public int startingPitch = 4; public int decreaseAmount = 5; public Spin spin; private AudioSource _audioSource; void Start() { _audioSource = GetComponent<AudioSource>(); _audioSource.pitch = startingPitch; } void Update() { if (_audioSource.pitch > 0) { _audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; } } } 

Screenshot of the propeller object :

propeller

and a screenshot of the empty gameobject with the audio source :

empty gameobject

The pitch in the audio source by default start at value 1 and be changed between the values -3 and 3. The rotation speed in the Spin script is in other units.

what i want to do is when i'm running the game and the propeller start rotating slowly to max speed that the pitch automatic will change it's value according to the propeller rotation speed so the pitch sound and the propeller rotation will be sync.

The script AudioExample as it is now making the pitch value to be much over the 3 value over 10. The calculation in the AudioExample script is wrong and i'm not sure how to do it :

_audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; 
Source Link
Daniel Lip
  • 1.8k
  • 4
  • 40
  • 81

How to change pitch value according to airplane propeller rotation speed?

I have some airplane with a propeller and a script attached to the propeller making the propeller start spinning when running the game from slow to max speed.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spin : MonoBehaviour { public float RotationSpeed = 1; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.Rotate(0, 0, RotationSpeed, Space.Self); if (RotationSpeed < 10) { RotationSpeed += 1f * Time.deltaTime; } } } 

on empty gameobject i added audio source and dragged to it a mp3 sound effect of propeller and also attached to the empty gameobject a script and dragged to the script the propeller object with the Spin script :

using System.Collections; using System.Collections.Generic; using UnityEngine; public class AudioExample : MonoBehaviour { public int startingPitch = 4; public int decreaseAmount = 5; public Spin spin; private AudioSource _audioSource; void Start() { _audioSource = GetComponent<AudioSource>(); _audioSource.pitch = startingPitch; } void Update() { if (_audioSource.pitch > 0) { _audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed; } } } 

Screenshot of the propeller object :

propeller

and a screenshot of the empty gameobject with the audio source :

empty gameobject

The pitch in the audio source by default start at value 1 and be changed between the values -3 and 3. The rotation speed in the Spin script is in other units.

what i want to do is when i'm running the game and the propeller start rotating slowly to max speed that the pitch automatic will change it's value according to the propeller rotation speed so the pitch sound and the propeller rotation will be sync.

The script AudioExample as it is now making the pitch value to be much over the 3 value over 10. The calculation in the AudioExample script is wrong and i'm not sure how to do it :

_audioSource.pitch += Time.deltaTime * startingPitch / spin.RotationSpeed;