Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Harry64 · Dec 12, 2013 at 09:11 PM · rotationaudiosounddoornormalized

Sound play with the speed of the rotation speed of an object.

ok.... I try to describe what I want to make.

I plan to create a special door sound system.... I want that the player is able to rotate a door via mouse imput (back and forward). the door can rotate ... let us say 120° degrees. that is the maximum. minimum is 0° degrees.

what I want to achieve is that there should be a squeaking sound BUT it should not play the sound fully when I grab the door and move it. it should play with the speed that the door rotates (audio pitch) + it should be perfectly fit with the door rotation degrees.

that means I would need normalized variables. like if the sound is at normal speed 3 seconds long. then the sound time (or position) normalized would be:

0.00 seconds = 0

1.50 seconds = 0.5

3.00 seconds = 1

and the door rotation degree normalized would be:

0° = 0

60° = 0.5

120° = 1

SOOOO.... Is it somehow possible to normalize the sound like I wrote above that it plays with the normalized speed?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Josh707 · Dec 13, 2013 at 02:20 AM 1
Share

I don't know how you would play the sound properly, but you can 'normalize' the time by dividing the doors rotation by whatever you limit it to. 120/120 = 1, 60/120 = 0.5, etc.

You can use AudioSource.time to set the current playback position although I don't know how mangled your audio will sound if you're playing it and scrubbing time constantly.

A better approach (in my opinion) is to simply have a looping sound who's pitch and volume is dependent on the doors angular velocity. I accomplished a really good sounding door swinging sound using this concept.

avatar image Harry64 · Dec 13, 2013 at 05:14 PM 0
Share

I tryed it now like you wrote here before I watched your comment and I have a little problem with the solution. I mean it works perfect with the door time like I wanted but when the door is pendeling very fast backwards and forwards it sounds very weird when the pitch gets fast to 0 and then back up. I tryed to lower with the speed ot the door the audio.volume but it sounds still weird. here is my script maybe you have any idea how to mitigate the weird sound...

 #pragma strict
 
 var doorDegreeLastFrame : float = 0.0;
 var doorDegreeNow : float = 0.0;
 var doorSpeed : float = 0.0;
 
 function FixedUpdate()
 {
     doorDegreeNow = hingeJoint.angle;
     doorSpeed = doorDegreeNow - doorDegreeLastFrame;
     doorDegreeLastFrame = doorDegreeNow;
     
     audio.pitch = doorSpeed;
     audio.volume = $$anonymous$$athf.Abs($$anonymous$$athf.Clamp(doorSpeed,-1,1));
 }
avatar image Josh707 · Dec 13, 2013 at 06:44 PM 0
Share

Yeah, you'll have to clamp the pitch to get it to sound right, it'll depend on your audio but I have $$anonymous$$e clamped between 0.85 & 1.

1 Reply

· Add your reply
  • Sort: 
avatar image
-1
Best Answer

Answer by Harry64 · Dec 13, 2013 at 07:59 PM

but that would not work correctly here... see, I try to create the door sound as realistic as possible. so if I would clamp the audio pitch between 0.85 and 1 I would end up with only positive sounds that would always play.

in my script above the sound is able to play backwards. and the squeaky sound is always in the same position now. like you open a real door. the squeaks are always at the same positions. like at 30 degrees there starts the squeak and goes over to 70 degrees and another starts at 100 and goes over till 110 degrees.

but I think now I got an idea... maybe I can slow down the door so it wont be able to be opened and closed very very fast. then it would not sound so weird.... (tested.... its better but not ok...)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Josh707 · Dec 14, 2013 at 03:01 PM 0
Share

Weird, any time I try to use negative pitch it just goes silent, glad you got it figured out though! And yeah since pitch can go all the way up to 3 it will get really high pitched.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

This door script causing door to go crazy? 2 Answers

Make door play sound when you open and close it ? 1 Answer

How would I reference the end of audio? 0 Answers

Door Opens When Not In Trigger And Sound Help 1 Answer

audio change object size 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges