problem with vector3.Angle with a fixed joint

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?
i include the project


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;

case direccion.y:
valor = transform.up;
case direccion.z:
valor = transform.forward;
Vector3 targetDir = target.position - transform.position;
Vector3 forward = transform.forward;
float anguloMedida = Vector3.Angle(targetDir, valor);
print (anguloMedida);	


I don’t understand those numbers, but maybe using transform.forward is the problem?

transform.forward is your personal forward, the blue arrow. It spins as the pivot spins, so they cancel. It’s like driving a car in a circle while checking if the passenger is on your left or behind you.

Seems like there should be one fixed reference, such as comparing to up: Angle(Vector3.up, target.position - transform.position).

Oh my god, its fixed now, you are right, i have to use vector3.up, i copy the code from the script reference they should change this, anyway thanks very much.