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
1
Question by Pure Phase · Apr 24, 2010 at 01:58 PM · audiomaterialsfootsteps

What's the easiest way of changing footsteps sound depending on floor material?

Hi

I know basically nothing about coding and have so far just been taking scripts from various places in order to get my game to work. At the moment I have a script which plays random footstep sounds when I walk, which is fine, but I want to change these when the character is walking on certain materials. I have seen there seems to be several ways of doing this but I am a bit confused as to how I should go about doing it. My theory is that I would just make a box collider and then if the player is walking through it, it will play different sounds to when they aren't. I've got no idea how to do this however. If someone could just point me in the right direction I'm sure I could work it out. Thanks!

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Peter G · Apr 24, 2010 at 02:22 PM

I believe the 2D platform tutorial uses triggers and tags

Two ways you could do it include:

1 Like you said, placing a large box collider marked as a trigger and tagged whatever material. Let's say "WoodFloor". Then your character would have a script with :

function OnTriggerStay (col : Collider) {

  if (!col.tag) return;     

  var floorType : String = col.tag;

  switch(floorType) {
      case "WoodFloor":
             // play wood floor footsteps.
           break;
      case "MetalFloor":
           // play metal footsteps
           break;
      default: //if the tag is not a floor type
           break;
  }

}

2 Another very similar way would be to tag the floor and use OnControllerColliderHit or OnCollisionEnter to find the tag of the floor and play footsteps accordingly. The code is almost identical to the code above.

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 Pure Phase · Apr 24, 2010 at 07:37 PM 0
Share

Hey, thanks for this I did manage to get it working. However, it seems to just play the audio I have on a constant loop and very quickly. I have been playing around for a couple of hours now with a few different codes but I've not managed to come up with anything, as I say my coding knowledge is pretty much nil. Basically I have the footsteps code from the fpstutorial, which works well. All I need to do is to say - if the player is in a box collider, play the sounds from var A, if not play them from var B, but I can't seem to work this out! :( Thanks for your help though

avatar image
0

Answer by duck · Apr 24, 2010 at 04:21 PM

A good way is to create a sound with the same name as each material used as ground, then just detect the material's name of the ground under the player, and play the corresponding footstep sound based on its string name.

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 user-9662 (google) · Feb 24, 2011 at 07:43 PM 0
Share

Hello, I was wondering if there are any examples of this? I have used something similar in a previous projet\ct so I am familiar with the concept, but i am unable to find any info on detecting material under the player (or on a specific poly collision etc.) Thanks so much for any help!

avatar image
0

Answer by PeterDC · Oct 01, 2010 at 01:26 PM

In Unity 3 you can now use Audio Reverb Zones to easily change the way your footsteps sound.

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

AngryBots MaterialImpactManager Script and FootstepsAudio 1 Answer

Different Surface Footstep Sounds Whilst using W and E keys for footstep input 2 Answers

Switch Audio on Different surfaces 0 Answers

Varied footsteps - Object reference not set to an instance of an object? 2 Answers

Random footstep sounds not looping 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