- Home /
Question by
CalebFnord · Feb 28, 2013 at 09:02 AM ·
rotationcollisionrigidbodysweeptest
Rigidbody.SweepTest - Local or Global axis?
When I run a SweepTest along some Vector3 direction on a Rigidbody object - Does Unity perform that test on a direction relative to that object's rotation or is sweeping on the global, absolute directions?
Thanks!
Comment
Answer by aldonaletto · Feb 28, 2013 at 11:43 AM
Except for the Relative functions (AddRelativeForce, AddRelativeTorque etc.), all Physics functions use world space - you can see this in the SweepTest example (reproduced below), where transform.forward is used to get the rigidbody forward direction in world space:
var hit : RaycastHit;
function Update () {
// Cast rigidbody shape 10 meters forward, to see if it is about to hit anything
if (rigidbody.SweepTest (transform.forward, hit, 10)) {
Debug.Log(hit.distance + "mts distance to obstacle");
}
}
Your answer
Follow this Question
Related Questions
Rotate Object inside room according to wall 0 Answers
How to anchor object on ground? 1 Answer
Rigidbody Inside Rigidbody 2 Answers
Get angle from impact 2 Answers