Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 kardamzaimov · Apr 16, 2018 at 05:00 PM · audiosoundcolider

Different sound the higher I go on the surface

I want when walking around with a character, footsteps or me colliding with the surface to sound differently, the higher/lower I go.

Sounds should preferably be not random, but a higher tune for the higher I am etc. or at least similar highs should have similar sounds (even if sounds are random).

Here is an example of a surface. P.S. I am desperate.

alt text

image-for-upload.jpg (521.4 kB)
Comment
Add comment · Show 9
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 TreyH · Apr 16, 2018 at 05:04 PM 0
Share

Is there a reason why you don't just set the pitch to something proportional to your character's vertical component?

avatar image kardamzaimov · Apr 16, 2018 at 06:36 PM 0
Share

How do I do that TreyH?

avatar image TreyH kardamzaimov · Apr 16, 2018 at 06:43 PM 0
Share

Assu$$anonymous$$g your footstep sound effect is using an AudioSource, there is a pitch property you can use.

I don't remember the know the default value for`pitch` with AudioSource components, but you'd so something like:

 audioSource.pitch = DEFAULT_PITCH + HEIGHT_TO_PITCH_RATIO * (DEFAULT_HEIGHT - this.transform.position.y);


where the values in caps are parameters you will choose based on your situation.

avatar image kardamzaimov TreyH · Apr 16, 2018 at 06:47 PM 0
Share

Thank you. Let me try. I need just to figure out how scripting works in unity haha I am a total beginner

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by TreyH · Apr 16, 2018 at 07:26 PM

This was discussed in the comments:

 using UnityEngine;
 
 // Attach this to something in your scene, preferably the player object
 public class PitchAdjustment : MonoBehaviour
 {
     // The AudioSource we're adjusting and the object whose height will adjust this pitch
     // 
     // These MUST be assigned in the inspector.
     //
     public AudioSource audioSource;
     public Transform targetTransform;
 
     // You will want to tune this as needed
     public float pitchToHeightRatio = 10;
 
     // Base values
     private float defaultPitch;
     public float defaultHeight;
 
     // Initialize our values with those components
     void Awake() 
     {
         this.defaultPitch = this.audioSource.pitch;
         this.defaultHeight = this.targetTransform.position.y;
     }
 
     void Update() 
     {
         // Adjust the pitch each frame
         this.audioSource.pitch = this.defaultPitch + this.pitchToHeightRatio * (this.defaultHeight - this.targetTransform.position.y);
     }
 }
Comment
Add comment · Show 3 · 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 kardamzaimov · Apr 16, 2018 at 07:56 PM 0
Share

medianHight was missing, but even when adding public float medianHeight , still says script can not be loaded

avatar image TreyH kardamzaimov · Apr 16, 2018 at 08:01 PM 0
Share

Updated for default height, what error is it giving you? Did you name the script correctly?

avatar image kardamzaimov · Apr 16, 2018 at 08:15 PM 1
Share

Worked great, thank you

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

99 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

help with multiple sounds 0 Answers

Audio doesn't play 1 Answer

NGUI Volume And Quality Controle With Sliders Not working 1 Answer

Play from a variety of sounds? 1 Answer

multiple sounds, sound....sucky 0 Answers


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