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 aaron524 · Nov 22, 2012 at 02:53 PM · texturefirst person

First Person Controller Detect Texture

Hello, I'm new to Unity3D development and currently using the indie version. I have a basic scene with a terrain that has dirt, and grass textures, there is also a wooden bridge at one point. I'm looking to have step sounds played via the first person controller. I have a basic script that plays the sounds but I want to detect what kind of texture the player is on. What is the best way to go about doing this. Please, if you can, be as detailed as possible, I'm pretty new to this.

Thanks in advance!

Comment
Add comment · Show 1
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 dorpeleg · Nov 22, 2012 at 04:32 PM 0
Share

All I can think of is Terrain.terrainData but I never tried working with it.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by greatestprez · Nov 23, 2012 at 04:43 PM

Use trigger colliders. Example: pretend you have a straight dirt road that leads to a grassy meadow. you want to play a walking sound that matches the dirt road when you are on the road, and you want to play a walking sound that matches the grassy meadow when you are on the meadow. To accomplish this, you can create a an empty object containing a trigger collider that stretches the length of the road, and then do the same for the meadow. You can then apply a simple script to each object containing the trigger collider (the 2 empty objects you created before). The scripts would make use of the OnTriggerEnter() and OnTriggerExit() functions to detect when the player enters and exits each area. The two functions would look something like this:


 void OnTriggerEnter(Collider col) { // this will be triggered when the player enters
     if (col.gameObject.tag == "player") { // make sure your player has the tag "player"
     
           // insert code to play sound here
 
     }
 }
 
 void OnTriggerExit(Collider col) { // this will be triggered when the player exits
   if (col.gameObject.tag == "player") { // again, make sure your player has the tag "player"
     
           // insert code to stop sound here
 
     }
 }
 
 
  
Comment
Add comment · Show 2 · 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 dorpeleg · Nov 23, 2012 at 07:31 PM 0
Share

Yes, that's one way of doing it but will require lots of different tirggers for a large map.

avatar image greatestprez · Nov 23, 2012 at 08:52 PM 0
Share

True, but I don't think there is a way to detect textures, so triggers are the best way to solve the problem in my opinion.

avatar image
0

Answer by SuarescorX · Mar 03, 2014 at 12:05 AM

There is a nice way, but is unofficial :D

http://answers.unity3d.com/questions/34328/terrain-with-multiple-splat-textures-how-can-i-det.html

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

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to gradient-wise fill a bitmap programmatically 1 Answer

How would I implement this game mechanic? 0 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Activating GUI 2 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