Hi there, I am trying to place a transform object in the position of the end point of a ray. As you can see that the yellow line was drawn using the following code: Debug.DrawRay(ahead.position, (temp.position - transform.position).normalized * 4, Color.yellow);
Correct me if I am wrong but the line above draws a ray from the ahead.position and points in a direction which is (temp.position-transform.position). I want the “temp2” object to be placed at the end of the ray that I just drew. I want it to appear at the position of the white “X” in the picture.
Ok so I got it. Its actually quite simple and I realized how to do it just a couple of minutes after posting the question :p. All you have to do is take a vector which points from the position of the capsule to the “temp” vector, scale it and then add that to the “ahead” vector. In the end the code looked something like this:
Vector3 someVector=ahead.position + (temp.position - transform.position).normalized * someScale;
temp2.positon=someVector;
Thats it!