i need measure angle of a rigidbody conected to a fixed joint, but inside the simulation the results are incorrect. i am using vector3.angle.
i need simulate a pendulum and measure the angle of the pendulum, any help?
project here
this is the code:
using UnityEngine;
using System.Collections;
public class angulo : MonoBehaviour {
public Transform target;
public float anguloMedida;
public enum direccion{x,y,z}
public direccion direccionActual = direccion.x;
Vector3 valor;
void Update()
{
switch (direccionActual)
{
case direccion.x:
valor = transform.right;
break;
case direccion.y:
valor = transform.up;
break;
case direccion.z:
valor = transform.forward;
break;
}
Vector3 targetDir = target.position - transform.position;
Vector3 forward = transform.forward;
float anguloMedida = Vector3.Angle(targetDir, valor);
print (anguloMedida);
}
}