fork download
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class normalDirectionScript : MonoBehaviour {
  5.  
  6. int count = 0;
  7.  
  8. // Use this for initialization
  9. void Start () {
  10. //transform.rotation = transform.rotation * Quaternion.AngleAxis(45, (new Vector3(1,1,1)).normalized);
  11. }
  12.  
  13. [SerializeField]
  14. GameObject aaa;
  15.  
  16. // Update is called once per frame
  17. void Update () {
  18. //法線を取得
  19. count++;
  20. Vector3 normalVector = new Vector3(Mathf.Sin(count / 10.0f), 1, Mathf.Cos(count / 10.0f));
  21. normalVector.Normalize();
  22.  
  23. Vector3 cross = Vector3.Cross(transform.up, normalVector).normalized;
  24. float dot = Vector3.Dot(transform.up, normalVector);
  25. float angle = -Mathf.Acos(dot) * Mathf.Rad2Deg;
  26.  
  27. transform.rotation = transform.rotation * Quaternion.AngleAxis(angle, cross);
  28. transform.rotation = transform.rotation * Quaternion.AngleAxis(5, Vector3.up);
  29.  
  30. //以下デバッグ
  31. Debug.Log("-----------------------");
  32. Debug.Log(transform.up);
  33. Debug.Log(normalVector);
  34. Debug.Log(cross);
  35. Debug.Log(dot);
  36. Debug.Log(angle);
  37.  
  38. aaa.transform.position = transform.position + transform.up * 5;
  39. }
  40. }
  41.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing an assembly reference?
prog.cs(4,38): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
prog.cs(14,2): error CS0246: The type or namespace name `GameObject' could not be found. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
stdout
Standard output is empty