How to get position of one point when a object move one place to another place will hit it?

There is a tank on the ground. But my camera is under the ground. I want to move camera to ground and do not change the direction between tank and camera. So i need the position of this place. I kown the funciton named “Trace” of UDK can do this. How to get it in unity3d?

1 Answer

1

Physics.Raycast

… wow, they named their raycast something besides raycast? ._.

No,like this photo.[10378-qq截图20130424140443.png|10378] The positions of object A and Camera B are known, how to get C point position?

raycast. -_- Ray ray = new Ray(); ray.origin = A; ray.direction = B - A; RaycastHit hit = new RaycastHit(); if ( Physics.Raycast(ray, out hit) ) { C = hit.point; } You might need to use "Layer Masks" to make the ray only be able to hit the ground.

My problem is solved.Thank you.