- Home /
Adjust Y-axis
I need to tranform an object to a certain place witch depend on a player. I can calculate x and z axis but not y. The problem is that terrain is not flat and i need that boject to be grounded.
Comment
Answer by robertbu · Jan 25, 2014 at 01:13 PM
Assuming you are talking about a Terrain, you can use Terrain.SampleHeight(). There is a sample script at the link. If your pivot of your character is not at the feet, you will have to add a constant to the value returned.
An alternate solution (that also works for non-Terrain objects) is to raycast down and use the hit point to adjust the 'y' position.
Your answer