- Home /
play sound when player reaches a certain speed
I want to have a sound play when I reach the speed of sound in my plane (721 mph). But my script isn't working.
I have:
var mph = rigidbody.velocity.magnitude *2.2369; function FixedUpdate(){
if (mph = 721) { audio.Play(); }
}
Any help?
Answer by Eric5h5 · May 14, 2010 at 04:47 PM
You have to use == when making comparisons. = is only for assignments. Also, the odds of the mph variable ever being exactly 721 are practically nil. It should be
if (mph >= 721.0)
Your answer
Follow this Question
Related Questions
How I can change the speed of an object with the speed of sound so they are evenly matched? 2 Answers
Velocity powered rigidbody on a moving platform without parenting. 3 Answers
Audio Velocity 1 Answer
How can I use Unity's Doppler effect with high velocity objects? 1 Answer
Audio Low Pass Filter Not Working 1 Answer