> For the complete documentation index, see [llms.txt](https://maxstvps.gitbook.io/documentation-eng/-MbEQLJaN0vXKGxXQmJX/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maxstvps.gitbook.io/documentation-eng/-MbEQLJaN0vXKGxXQmJX/samples/placement-by-raycast.md).

# Placement by Raycast

## Placement by Raycast

This is a sample of placing 3D objects on to the surface of buildings with the point of contact. Using mouse or touch panel, ray is casted that connects to camera's focal point, and thus calculate code based on transactional points with building mesh.

{% code title="MaxstSceneManager.cs" %}

```bash
public void AttachLogo()
{
    Vector2 vTouchPos = Input.mousePosition;

    Ray ray = Camera.main.ScreenPointToRay(vTouchPos);

    RaycastHit vHit;
    if (Physics.Raycast(ray.origin, ray.direction, out vHit))
    {
        maxstLogObject.transform.position = vHit.point;
        maxstLogObject.transform.rotation = Quaternion.FromToRotation(Vector3.forward, vHit.normal) * Quaternion.Euler(-90.0f ,0.0f, 0.0f);
    }
}
```

{% endcode %}

![Example of Placement by Raycasting](https://3673497343-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mb9PH5wRNtA8vy7FYv1%2F-MbC6Nqvlrn0ICE9kzzi%2F-MbC6a5t2vowOW0VjLVv%2Fimage.png?alt=media\&token=a9f70801-a9a6-4b8e-b5a8-9e6e49ba2d33)
