Jump to content
  • Advertisement
Sign in to follow this  
adder

Unity Terrain affected movement [Unity5]

This topic is 1259 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello

 

I've been trying to implement a movement system where objects move at a fixed pace relative to the terrain they're currently traversing. The terrain itself is just a flat plane with different regions, lets say: grass, rock, mud.

 

I'd love to get some suggestions on how to handle this, as I haven't been able to come up with a workable solution. I've tried having a grid of 1x1 Quads that advertise their terrain type and let the object adjust its speed accordingly, but that didn't give the wanted effect as I don't want grid based movement.

 

For now I'm thinking of adding different types of friction materials (but the question would again be how? afaik one would need some kind of in-logic generator that generates a bunch of meshes tailored to the shape of each surface region, and assign a Physic Material to that) however this would probably not work since if force 'F' keeps you at a constant speed at material 'M' with a certain friction, you'll not achieve a constant speed on a material with a different friction. (If my physics isn't failing me)

 

Long story short: I have no idea how to create a flat terrain with different surface types, each affecting the object's movement speed.

 

Thanks for your time. 

Share this post


Link to post
Share on other sites
Advertisement

Last time I did something like that, I didn't bother with having the geometry in the scene store the data, I had a texture map that stored the underlying terrain type. The terrain in that case was a subdivided quad that was UV'd, and the units on the terrain worked out where they were in the UV coordinates of the space and did a texture lookup to figure out the terrain type. Once I had that, I could use the value in a bunch of different calculations.

Share this post


Link to post
Share on other sites
Like the one above me. The best way to go about this is either by texture or materials. If your mesh caries data per poly, you will run into an issue where things are petty jagged, or very direct.

Share this post


Link to post
Share on other sites

The material way sounds probably the best way.  The crappy alternative that jumped to mind would be putting Colliders that are marked as triggers and having OnEnter and OnExit or something of that sort.  But if your terrain is at all large and/or varied, this would quickly become unmanageable.

Share this post


Link to post
Share on other sites

Thanks for your suggestions! I now have a working system based on texture mapping!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!