# How to get an angle with sine or cosine?

Hi everybody,
One of my scripts calculates the cosine of an angle by dividing one distance by another. My question is:
How can I get the angle when I have the cosine or sine? :?:

Use Mathf.Asin and Mathf.Acos (Mathf.Acos(x) basically means â€śthe angle whose cosine is xâ€ť).

Alternatively, you might be able to represent your distances as vector offsets from a corner point and use Vector3.Angle to get the result you want. No trigonometry required.

1 Like

Thanks andeeee

But itâ€™s not workingâ€¦
In my game, I want a character with a weapon to shoot on a point (letâ€™s call it point A) in the center of the field of view. I created the character with 5 different shoot animations for 5 different angles.
The problem is that I canâ€™t get the angle beetween the point A and the characters z-axis. I tried to use trigonometry, to access the main cameras rotation (by camera.transform.rotation.x) and many other ways but nothing happens, the character always schoots in one direction. :?

This is the targeting part of my code:

``````function Update () {
var target : RaycastHit;
if (Physics.Linecast (MainCamera.position, endPoint.position, target)) {
}

cameraAngle = Vector3.Angle(transform.forward,target.point);

// Play the shoot animation
if (Input.GetButtonDown ("Fire1")) {
// We are in idle so play it on the fully body
if (cameraAngle <= shootHeight1) {
}
if (targetAngle >= shootHeight1) {
}
}
}
``````

This is my character:

What you probably want is something like:-

``````var targetHeading = target.point - transform.position;
``````cameraAngle = mainCamera.eulerAngles.x