- Home /
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?
Answer by Loius · Apr 24, 2013 at 04:10 AM
... wow, they named their raycast something besides raycast? ._.
No,like this photo.
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 $$anonymous$$asks" to make the ray only be able to hit the ground.
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
Moving object to object (with Bezier Curve) doesn't land on it 0 Answers
Detecting the rotation of the current object? Shield resets when undertaking orbit. 2 Answers
Help! I want to make a following camera but in with Y position is constant ? 2 Answers
Character Can't Move After Teleporting? 0 Answers