# Vector equation for dragging a Quad billboarding the Camera

I am trying to implement method which allows the user to click on a quad with the mouse, and drag it around. While being dragged, the quad should be facing / billboarding the camera.

After several tries at this method which worked out more or less good, I finally found out where my confusion came from. The correct center point position is needed, but obtaining it can only be done through an equation solving with the giving parameters. But this is where my math fails me. Any help finding this equation would be greatly appreciated.

Please see the picture below for illustration. It's a 3D world, but for the sake of simplicity the picture is in 2D.

The user clicks on the quad, which gives the 3D point where the quad was hit and the direction from the camera to it. Dragging the quad around should now orient it facing the camera, constantly billboarding it at the same distance while being dragged and using its center point (A) for pivoting.

This gives three values which can be used:

The direction from the cam to the quad point that was clicked on with the mouse

The distance between the camera and the center point of the quad, when it was clicked on.

The size of the quad (and the distance between its center point and the point where it was clicked)

The problem can probably be solved by finding the position where the quad center point is at the required distance and maintaining its offset to the drag point where the user clicked it. So basically, given the mousepointer direction and the quad size, the position of the quad center point is needed where it intersects the circle around the camera of the given distance.

Any help how to come up with that equation would be greatly appreciated.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

how to calculate the angle between two vectors? 6 Answers

Check if Dump's velocity is zero 0 Answers

How to tell unity to use the 9th overhead image of Tree Billboard when the camera is overhead? 0 Answers

Creating Random object in random axis 0 Answers

Why is Vector2.Angle() returning 90 regardless of input for me? 1 Answer