# Throw 3D object parabolically -> From 2D Canvas to WorldSpace

I created 2 cameras 1 for the 3D object rendering for UI and other one basicly rendering the whole scene.

My question is how can I create object and throw parabolically from UI 3D object position to world space position ?

Hi.

Here is how I think I would proceed.

First thing would be to instantiate the 3D cube you want to throw, considering the one shown in the UI is only a rendering texture.

You will calculate its initial 3D position (and maybe also its scale and rotation) in order to give the impression that it’s thrown from the UI.

For the position, use Camera.ScreenToWorldPoint(), like this :

Camera cam; // this is your 3D cam
GameObject UIcube; // this is your UI element showing the cube
GameObject prefabCube; // no comment

float x = UIcube.transform.position.x;
float y = UIcube.transform.position.y;
float z = -cam.transform.position.z;
Vector3 initPoint = cam.ScreenToWorldPoint(new Vector3(x, y, z));

GameObject cube = Instantiate (prefabCube, initPoint, someRotation);

For the motion, it depends.

I hope you don’t want it based on physics because you would have to apply a very finely tuned force ; seems nearly impossible.
I would use an interpolation system like iTween.

For the parabolic motion, you could define a path using 3 points : the start point (initPoint), the target point and an intermediary one ; this one would be positioned between the start and target points, but with some x offset so that the path becomes a curve.

An example :

Vector3 initPoint; // the one we just defined
Vector3 targetPoint; // the end of the road ;)
Vector3 interPoint = targetPoint - initPoint;
interPoint.x += Random.Range(1f, 3f); // give a random offset for curvature
Vector3 [ ] path = new Vector3 [ ] {initPoint, interPoint, targetPoint};

// finally, do the motion :
iTween.MoveTo(cube, iTween.Hash(
"path", path,
"time", 2f,