Comments and answers for "Trouble Understanding Vector3.Angle() Result"
http://answers.unity.com/questions/814563/trouble-understanding-vector3angle-result.html
The latest comments and answers for the question "Trouble Understanding Vector3.Angle() Result"Comment by Bunny83 on Bunny83's answer
http://answers.unity.com/comments/815245/view.html
@popuppirate: Your radians to degrees factor is wrong ^^
Either use
(180 / Mathf.PI)
or
(360 / (2*Mathf.PI))
But since Unity has this value [as constant][1] the easiest and safest way is to simply use
Mathf.Rad2Deg
[1]: http://docs.unity3d.com/ScriptReference/Mathf.Rad2Deg.htmlThu, 23 Oct 2014 01:59:45 GMTBunny83Comment by boddole on boddole's answer
http://answers.unity.com/comments/815225/view.html
This is off the top of my head, so sorry if it's not what you were after!
-> Not quite, but I still appreciate the effort.Thu, 23 Oct 2014 01:18:03 GMTboddoleComment by boddole on boddole's answer
http://answers.unity.com/comments/815223/view.html
Right on the money! Thank you.Thu, 23 Oct 2014 01:16:45 GMTboddoleComment by SimonTS on SimonTS's answer
http://answers.unity.com/comments/815039/view.html
To illustrate this (shortly after collision occured):
![vectors during collision][1]
[1]: /storage/temp/34128-impact.jpgWed, 22 Oct 2014 20:39:35 GMTSimonTSAnswer by SimonTS
http://answers.unity.com/answers/814881/view.html
You should not use your rigidbody velocity for this. Instead use the relativeVelocity field of your Collision object, like this:
void OnCollisionEnter(Collision other) {
float angle = Vector3.Angle(other.relativeVelocity, other.contacts[0].normal));
// do stuff with angle
}
This will give you the angle between your projectile and the other colliders surface normal.
lgWed, 22 Oct 2014 17:40:27 GMTSimonTSAnswer by popuppirate
http://answers.unity.com/answers/814638/view.html
Try the following:
float angle = Vector3.Angle (thisRigidbody.transform.position.up, transform.somereference.up);
Make a reference object that is flat and non kinematic, like a plane, and use this as an up reference. The angle function will return the angle from the rigidbody's up to the reference's up in radians.
Convert radians to degrees with (180/(2*Mathf.PI))
This is off the top of my head, so sorry if it's not what you were after!
Cheers,
PopuppirateWed, 22 Oct 2014 12:03:05 GMTpopuppirate