How to cast a Ray using local pivot of an object?
How can I cast a Ray from the position of the object toward the other way of the X local pivot arrow like i show with the green arrow in the screenshot? I want to use the local pivot point because if i rotate the Tile i want the Ray to rotate too.
I use this code but the results are not what i want
RaycastHit hit;
if (Physics.Raycast(transform.position, -transform.right, out hit, maxRayDis)) {
Debug.DrawLine (transform.position, -transform.right*maxRayDis, Color.green);
}
Answer by hexagonius · Nov 17, 2016 at 11:18 AM
your raycast is correct, your Debug is wrong. Drawline is a from to while drawray is a from along
Your answer
Follow this Question
Related Questions
Disable a UI element when ray doesn't hit it anymore. 1 Answer
Raycast hit not working when GameObject is changed 0 Answers
Raycast doesn't stay in one place 0 Answers
RayCast(Ray ray, out RaycastHit hitInfo, float maxDistance, int layerMask) question 0 Answers
Physics.Raycast Not Working... Kinda 0 Answers