Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var spray : GameObject;
- private var canSpray : boolean = true;
- private var numQuads = 10000;
- private var verts = new Vector3[numQuads * 4];
- private var uv = new Vector2[numQuads * 4];
- private var tris = new int[numQuads * 6];
- private var cv : int;
- var thecam : Camera;
- var mat : Material;
- private var mesh = new Mesh();
- private var matPropBlock = new MaterialPropertyBlock();
- function Start () {
- for (var n=0; n< numQuads; ++n)
- {
- tris[n*6 + 0] = n*4 + 0;
- tris[n*6 + 1] = n*4 + 1;
- tris[n*6 + 2] = n*4 + 2;
- tris[n*6 + 3] = n*4 + 0;
- tris[n*6 + 4] = n*4 + 2;
- tris[n*6 + 5] = n*4 + 3;
- uv[n*4 + 0] = Vector2(0,0);
- uv[n*4 + 1] = Vector2(0,1);
- uv[n*4 + 2] = Vector2(1,1);
- uv[n*4 + 3] = Vector2(1,0);
- }
- GetComponent (MeshFilter).mesh = mesh;
- mesh.vertices = verts;
- mesh.uv = uv;
- mesh.triangles = tris;
- }
- function Update () {
- if(Input.GetButtonDown("Jump")){
- canSpray = false;
- }else if(Input.GetButtonUp("Jump")){
- canSpray=true;
- }
- if(canSpray){
- if(Input.GetButtonDown("Fire1")){
- InvokeRepeating("SprayIt", 0, 1);
- }
- if(Input.GetButtonUp("Fire1")){
- CancelInvoke();
- }
- }
- }
- function SprayIt(){
- var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
- var hit : RaycastHit;
- //var localPos = transform.InverseTransformPoint(hit.point);
- if (Physics.Raycast (ray, hit, 100)) {
- //print ("Hit something");
- }else{
- //print ("No hit");
- }
- if(hit.collider.gameObject.name == "Side"){
- print (cv);
- verts[cv*4 + 0] = Vector3(0,0,0);
- verts[cv*4 + 1] = Vector3(0,1,0);
- verts[cv*4 + 2] = Vector3(1,1,0);
- verts[cv*4 + 3] = Vector3(1,0,0);
- print (verts[21]);
- cv = cv + 1;
- DrawMesh(mesh, Vector3(0, 0, 0), Quaternion.identity, mat, 0, thecam, 0, matPropBlock);
- //print (hit.point.z);
- //var theSpray : GameObject = Instantiate(spray, Vector3(hit.point.x, hit.point.y, hit.point.z), Quaternion.identity);
- //theSpray.transform.up = hit.normal;
- //theSpray.transform.parent = hit.collider.gameObject.transform;
- }
- }
- function DrawMesh(mesh : Mesh, position : Vector3, rotation : Quaternion, material : Material, layer : int, camera : Camera, submeshIndex : int, properties : MaterialPropertyBlock) {
- }
Advertisement
Add Comment
Please, Sign In to add comment