direction to angle unity code example

Example 1: get angle between two vectors unity

Vector3 targetDir = target.position - transform.position;
float angle = Vector3.Angle(targetDir, transform.forward);

Example 2: how to offset vector 3 by an angle unity

Vector3 noAngle = spawn.forward; Quaternion spreadAngle = Quaternion.AngleAxis(-15, new Vector3(0, 1, 0)); Vector3 newVector = spreadAngle * noAngle;  Ray ray = new Ray (spawn.position, newVector);  CastProjectiles(shotDistance, ray);