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?

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);
}
}

help with this, please

Well, if up is always up, you could use something like this:

float angle = Vector3.Angle(Vector3.down, restrictedJointCube.transform.position - fixedJointCube.transform.position);

This gives you an angle between what is down and what is the normal between them.