x


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?

more ▼

asked May 14 '10 at 04:25 PM

Fishman92 gravatar image

Fishman92
2.4k 101 113 128

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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)
more ▼

answered May 14 '10 at 04:47 PM

Eric5h5 gravatar image

Eric5h5
80.2k 41 132 519

thanks for that :D

May 14 '10 at 04:53 PM Fishman92
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1026
x318

asked: May 14 '10 at 04:25 PM

Seen: 1206 times

Last Updated: May 14 '10 at 04:25 PM