Monument Valley, example Picture:
Note that the FBX import new project File scale shrinks and needs to be scaled up by scaling Factor
Special meshfilter material is required. Download Address: Http://pan.baidu.com/s/1jIbnQfG
The code is as follows:
Using Unityengine;
Using System.Collections;
Using System;
public class Twistscript:monobehaviour {public float twist = 1.0f;
public float inputsensitivity = 1.5f;
Private vector3[] basevertices;
Private vector3[] basenormals;
Private Vector3 New_pos; Update is called once per frame void Update () {twist + Input.getaxis ("horizontal") * inputsensitivity
* TIME.DELTATIME;
Limit twist Range if (Twist <-2) {twist =-2;
} if (Twist > 2) {twist = 2;
Mesh mesh = getcomponent<meshfilter> (). Mesh;
if (basevertices = = null) {basevertices = mesh.vertices;
} if (basenormals = = null) {basenormals = mesh.normals;
} vector3[] vertices = new vector3[basevertices.length];
vector3[] normals = new Vector3[basenormals.length]; for (int i = 0; i < vertices. Length;i++) {Vertices[i] = Dotwist (Basevertices[i], basevertices[i].y * twist);
Normals[i] = dotwist (Basenormals[i], basevertices[i].y * twist);
} mesh.vertices = vertices;
Mesh.normals = vertices; Mesh.
Recalculatenormals (); Mesh.
Recalculatebounds ();
}//produces twisted private Vector3 dotwist (Vector3 pos, float t) {Float St = Mathf.sin (t);
float ct = mathf.cos (t);
New_pos = Vector3.zero;
new_pos.x = pos.x * Ct-pos.z * ST;
new_pos.z = pos.x * St + pos.z * CT;
New_pos.y = Pos.y;
return new_pos;
}
}
the effect is shown in the following figure: