• 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 friketrike · Nov 05, 2012 at 01:26 AM · .objsplatmaps

I'd like to access terrain textures on a .obj terrain, any pointers?

Hi, I'm creating a demo for sound design and I want the character's steps to change according to the terrain's texture below the character (see http://answers.unity3d.com/questions/14998/how-can-i-perform-some-action-based-on-the-terrain.html , Ben Pitts' answer, since triggers would be a rather long route) but I just discovered that the level I'm using has a .obj terrain which I haven't been able to access via my C# scripts. Does anyone have a clue as to how I might go about this? I see I have access to a compiled shader but I don't really have a clue of how to modify it (assuming it's actually possible) to give me the values I'm looking for. I tried Obj2Terrain but I obtained a mesh with no textures, so it doesn't seem to be the right way. Thanks and cheers, F

Comment
Add comment · Show 5
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 cupsster · Nov 05, 2012 at 03:49 PM 0
Share

You can raycast for pixel color or for mesh material and make decision based on that.

avatar image friketrike · Nov 05, 2012 at 04:08 PM 0
Share

Ah, that sounds good; on to learn raycasting it is :) . Thanks for the tip. Cheers

avatar image friketrike · Nov 06, 2012 at 04:39 PM 0
Share

Ok, got raycast working but I get null for the raycastHit.collider.renderer and can't find anything of much use in the debugger when I explore the raycastHit instance from the hardcoded terrain (not so from added meshes such as rocks or other props where I do get a renderer and triangleIndexes as expected). Any other ideas? Thx and cheers, F

avatar image cupsster · Nov 06, 2012 at 04:50 PM 0
Share

$$anonymous$$ake just simple planar mesh with outlines of areas projected and tag them or use simple plane with color codded info and setup raycast matrix and collision layers corespondingly. Then you can ask unity for color code or area tag and process that info..

avatar image friketrike · Nov 07, 2012 at 04:05 AM 0
Share

Ok, so I managed to make a plane under my terrain with the original terrains' splatmask and get the pixel's color value through raycasting (which I also use for detecting rock or other props that would affect the sound of footsteps). Oddly enough, the other terrain's splatmask gets imported inverted on the y axis (inverted from the original terrain, that is) and raycasting on something with a single negative scale value seems to invert coordinates within each triangle in the mesh. It's really odd, so I just created a second inverted tif and used that but if you know why this happens I'd like to find out. (to reproduce, create a plane with a white texture and scale values of 1,1,-1. Then setpixel() to Color.black under a walking FPS. Watch this in the editor from above and you'll see that the black lines are symetric to the FPS' path within each triangle). Anyhoot, thanks for your help, it's working now ;)

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

11 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

Related Questions

Splatmap performance question 2 Answers

Export convex mesh collider data as .obj 0 Answers

Model expands on moving horizontally 1 Answer

Spalt Maps Problem.... 0 Answers

Importing .obj files with RGB data 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges