Well I want my mesh - plane should swim over water surface as paper. For that i would like modify position of mesh vertices, but my script doesn’t work (
function Start(){
thisMatrix = transform.localToWorldMatrix;
mesh= GetComponent(MeshFilter).mesh;
vertices = mesh.vertices;
}
function Update(){
for (var i = 0; i < vertices.Length; i++){
Mypos = thisMatrix.MultiplyPoint3x4(vertices*);*
Mypos.y+=20;*
if (Physics.Raycast (Mypos, -Vector3.up,hit, 30)) {*
I needed transform.worldToLocalMatrix to transform
world coordinates to local mesh coordinates. this whole script:
var mesh : Mesh;
var vertices : Vector3[];
var Mypos:Vector3;
var Mypos1:Vector3;
var hit : RaycastHit;
var thisMatrix: Matrix4x4;
var meshMatrix:Matrix4x4;
function Start(){
thisMatrix = transform.localToWorldMatrix;
meshMatrix = transform.worldToLocalMatrix;
mesh= GetComponent(MeshFilter).mesh;
vertices = mesh.vertices;
}
function Update(){
for (var i = 0; i < vertices.Length; i++){
Mypos = thisMatrix.MultiplyPoint3x4(vertices*);*
Mypos.y+=100;*
if (Physics.Raycast (Mypos, -Vector3.up,hit, 120)) {*