Created
May 28, 2014 09:38
-
-
Save dcrystalj/0411d7c9e9ea2d64ebb4 to your computer and use it in GitHub Desktop.
unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RaycastHit rcHit = new RaycastHit(); | |
Ray bottom = new Ray(this.transform.position,Vector3.down); | |
if (Physics.Raycast(bottom,out rcHit,20)) | |
{ | |
double posy = transform.position.y; | |
//with this you rotate object to adjust with terrain | |
transform.rotation = Quaternion.Slerp( | |
transform.rotation, | |
Quaternion.FromToRotation(Vector3.up*Time.deltaTime, rcHit.normal), | |
Time.deltaTime | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment