Location of raycast collision.

I want to instantiate a GameObject at the location a raycast collide with the mesh collider. How can i get the location of the collision?

You need to pass a "RaycastHit" object into the raycast function, and then if the raycast returns as true, the RaycastHit object's variables will be filled with data about the intersection, including the "point" variable, which gives the raycast collison location in world space.


var hit : RaycastHit;
if (Physics.Raycast (transform.position, -Vector3.up, hit, 100.0)) {
    Instantiate( sourceObject, hit.point, Quaternion.identity );