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
-1
Question by corriedotdev · Apr 24, 2013 at 09:00 PM · footstepsfoot

Footsteps on different terrain idea

I have a idea, im at college right now so cant get access to unity. Been on a roll with programming recently. If i make a extra variable in this code then a if statement that basically if a gameobject is hit then it changes the sound to the new variable? I will try it out later :) then i can add a new variable for all teh curface types and just add a plane onto the surface with mesh render off.. hmmm

 var footsteps : AudioClip;
 //INSERT NEW VARIABLE VAR MUD :Audioclip;
  
 
 function Start() 
 
 {
 
     audio.clip = footsteps;
 
     audio.loop = true;
 
 }

// function start_2 ()

{

     audio.clip = mud;
 
     audio.loop = true;
 
 }

 
  
 
 function Update()
 
 {
 
     if (Input.GetKeyDown (KeyCode.W))
 
     audio.Play();
 
     else if(Input.GetKeyUp (KeyCode.W))
 
     audio.Stop();
 
 }


I already see errors but what you guys think :) ill work on some pseudocode tonight

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Z2CSharp · Apr 25, 2013 at 01:43 AM

If you want to be able to detect what you are walking on you would definitely need a raycasthit and tags on your gameObjects to trigger the right audio

     private RaycastHit hit; // What terrain we hit
     public Transform Character_T; // The transform (Position) of our character
     
     private float Speed = 1.0f; // How fast the character moves
     
     void Update()
     {
         transform.Translate (0,0,Speed * Time.deltaTime);
         
         if(Physics.Raycast(Character_T.position,-Vector3.up,out hit,100.0f)) // Send out a ray from character position down at 100.0f, if java, forget the out modifier
         {
             print ("I be firing my ray");
         }
         
         if(hit.collider.tag == "Mud_Terrain" && Speed >= .1f) // If we are walking on mud terrain
         {
             audio.Play(); // Play the mud terrain audio
         }
     }

I didn't define a mud audio in the script though :(

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 corriedotdev · Apr 25, 2013 at 06:18 PM 0
Share

nice idea, obviously you would need to incorporate the if w is pressed part in there. I have actually got it working by a variety of different ways. just wanted to know if anyone else did what i said

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

12 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

Related Questions

FPS footsteps only work when jumping/hitting edges of a mesh 1 Answer

Random Footsteps with variable pitch and volume 1 Answer

How can I create headbobbing with footstep sounds and running? 1 Answer

Footstep Script (NullReferenceException: Object reference not set to an instance of an object) 1 Answer

Changing Footstep Sounds On Different Surfaces 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