SickTube.cs 912 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SickTube : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. void Start()
  8. {
  9. GetComponent<Rigidbody>().angularVelocity = new Vector3(0,10,0);
  10. Mesh mesh = this.GetComponent<MeshFilter>().mesh;
  11. Vector3[] normals = mesh.normals;
  12. for(int i = 0; i<normals.Length; i++){
  13. normals[i] = -1 * normals[i];
  14. }
  15. mesh.normals = normals;
  16. for(int i = 0; i< mesh.subMeshCount; i++){
  17. int[] tris = mesh.GetTriangles(i);
  18. for(int j = 0; j < tris.Length; j+=3){
  19. int temp = tris[j];
  20. tris[j] = tris[j+1];
  21. tris[j+1] = temp;
  22. }
  23. mesh.SetTriangles(tris,i);
  24. }
  25. }
  26. // Update is called once per frame
  27. void Update()
  28. {
  29. }
  30. }