Hello,
I want a sphere to follow my mouse, but I don’t want the sphere to use dept (Z axis). I basically want the ball to stick to my mouse position absolutely (like a custom curser texture)… But within my 3D scene.
What I’m trying to do, is that when you click on an object (a car) in the scene, a sphere pops up in the same 3D position as the car in the scene. You can then drag this sphere only X, Y on the screen so it appears its stuck to the mouse. Another note is that my camera can move around the scene (don’t know if that will effect the maths of my sphere)
This is what I have at the moment:
function Drag() {
selectedPullingPoint = currentSelected.GetComponent(JengaBlock).pullPoint;
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, Mathf.Infinity)){
if(!pullingApart){
start.position = selectedPullingPoint.position;
pullingApart = true;
}
//not used atm
var screenX = Input.mousePosition.x;
var screenY = Screen.height - Input.mousePosition.y;
//Rotate end object towards camera
//end.rotation = Quaternion.LookRotation(-Camera.main.transform.forward);
//Moves end object
end.position = hit.point; //Vector3(screenX, screenY, start.position.z);
end.position.z = start.position.z;
}
Thanks