Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PruebaMenu : MonoBehaviour {
- private Vector3 direction;
- private Vector3 directionNorm;
- private float radio = 2;
- private float anguloRaw;
- private float angulo;
- public int botones = 5;
- public GameObject[] botonesIconos;
- public GameObject bola;
- public static Transform camara;
- [SerializeField]
- private GameObject icono;
- void Start (){
- camara = GameObject.FindGameObjectWithTag ("MainCamera").transform;
- botonesIconos = new GameObject[botones];
- for(int i = 0; i < botones; i++){
- float theta = (2*Mathf.PI/botones)* i;
- 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);
- botonesIconos[i].transform.parent = transform;
- }
- }
- void Update () {
- direction = new Vector3( Input.GetAxis ("Horizontal")*(-1), 0, Input.GetAxis ("Vertical")*(-1));
- bola.transform.localPosition = Vector3.Lerp(bola.transform.localPosition, (direction.normalized * radio), 0.1f);
- transform.LookAt (camara);
- directionNorm = direction.normalized;
- if (direction.z > 0) {
- anguloRaw = Mathf.Acos (directionNorm.x);
- angulo = anguloRaw * Mathf.Rad2Deg;
- } else {
- anguloRaw = Mathf.Acos (directionNorm.x);
- angulo = anguloRaw * Mathf.Rad2Deg * -1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment