- Home /
How can i get point reletive to hit.point
How can i get the Vector3 point that is relative to the face hit. I am trying this script:
void DestroyBlock()
{
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, range))
{
// *** I dont know what to put in this line to make it work ***
Vector3 position = hit.point - hit.normal/2;
int x = (int) position.x;
int y = (int) position.y;
int z = (int) position.z;
print(x + " , " + y + " , " + z);
world.GetComponent<Generation>().data[x, y, z] = 3;
world.GetComponent<Generation>().CreateTerrain();
}
}
But the problem is that for some reason it wont get the point i am looking for. It is as if it is almost random. Im not sure why this script isnt working or how to fix it. Can anyone help? Thank you.
How about trying "localPosition" ins$$anonymous$$d of position? Same results?
I'm trying to get o.5f less than the place where it hit using the normal.
can you tell me exactly what you're trying to accomplish with the script? I see destroy block. Do you want to destroy the gameObject you click? If so, try using On$$anonymous$$ouseDown and Destroy(gameObject);
Your answer
Follow this Question
Related Questions
How i can a normal vectors? 3 Answers
Multiple Cars not working 1 Answer
setting camera to hit.point returning null vector 1 Answer
Distribute terrain in zones 3 Answers
How do I make it know what it's hitting? 3 Answers