Collisions = Get colliding vertices
JS is required but C# will do too
I need help to Get the vertices (or nearest vertices) of the collision and some explanation or some links to how to do it
Basically I use this script but I found out Contacts aren't in the form of vertices(Local Vector3) and I get an error
I need to get vertices and fix the error please I promise to upvote :p
//Javascript
#pragma strict
//Variables to show in inspecor
public var ObjectToDeform : Transform; //this gameObject
public var DeformMesh : MeshFilter;
public var OriginalVerts : Vector3[ ];
public var ModifiedVerts : Vector3[ ];
public var DamageDivider : float;
public var HP : float;
//Variables to hide in inspector
private var OTD: Transform;
private var DM = DeformMesh.mesh;
private var OV:Vector3[ ];
private var MV:Vector3[ ];
private var DD : float;
function Start () {
//Initialize all the variables
//The Object To Deform
OTD = ObjectToDeform;
//Original Verts
OriginalVerts = DM.vertices;
OV = OriginalVerts;
//Modified Verts
ModifiedVerts = OV;
MV = ModifiedVerts;
//Damage Divider
DD = DamageDivider;
}
function OnCollisionEnter(collision:Collision){
var CP = OV;
Deform(CP,collision.relativeVelocity.Magnitude);
}
function Deform(CV:Vector3[ ], CM:Vector3):void {
}
The error
error-log.png
(10.8 kB)
Comment
Your answer
Follow this Question
Related Questions
Triangles don't follow the vertices changed on mesh 1 Answer
Read Vertices in a specific order? 1 Answer
Edit SkinnedMesh with vertices 0 Answers
Mesh generation triangles issue 0 Answers
Removing Tris/Verts/Polygons from an merged mesh? (C#) 0 Answers