Guest User

Untitled

a guest
Jul 6th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PruebaMenu : MonoBehaviour {
  5.  
  6.  
  7. private Vector3 direction;
  8. private Vector3 directionNorm;
  9.  
  10. private float radio = 2;
  11.  
  12. private float anguloRaw;
  13. private float angulo;
  14.  
  15. public int botones = 5;
  16.  
  17. public GameObject[] botonesIconos;
  18.  
  19. public GameObject bola;
  20. public static Transform camara;
  21. [SerializeField]
  22. private GameObject icono;
  23.  
  24. void Start (){
  25. camara = GameObject.FindGameObjectWithTag ("MainCamera").transform;
  26.  
  27. botonesIconos = new GameObject[botones];
  28.  
  29. for(int i = 0; i < botones; i++){
  30.  
  31. float theta = (2*Mathf.PI/botones)* i;
  32.  
  33. botonesIconos [i] = (GameObject)Instantiate (icono,new Vector3 (bola.transform.position.x + Mathf.Cos(theta)*radio,bola.transform.position.y + Mathf.Sin(theta)*radio , bola.transform.position.z), Quaternion.identity);
  34.  
  35. botonesIconos[i].transform.parent = transform;
  36.  
  37. }
  38. }
  39.  
  40.  
  41. void Update () {
  42.  
  43. direction = new Vector3( Input.GetAxis ("Horizontal")*(-1), 0, Input.GetAxis ("Vertical")*(-1));
  44. bola.transform.localPosition = Vector3.Lerp(bola.transform.localPosition, (direction.normalized * radio), 0.1f);
  45.  
  46. transform.LookAt (camara);
  47.  
  48. directionNorm = direction.normalized;
  49. if (direction.z > 0) {
  50. anguloRaw = Mathf.Acos (directionNorm.x);
  51. angulo = anguloRaw * Mathf.Rad2Deg;
  52. } else {
  53. anguloRaw = Mathf.Acos (directionNorm.x);
  54. angulo = anguloRaw * Mathf.Rad2Deg * -1;
  55. }
  56.  
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment