Terrain affected movement [Unity5]

Started by
3 comments, last by adder 9 years ago

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.

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.

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.

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.

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

This topic is closed to new replies.

Advertisement