Hello,
How to apply to a Vector3 the same variation of another Vector3 ?
Here, I want to subtract from myPoint the movement of the camera.
Vector3 camPosition;
Vector3 myPoint;
Camera cam;
void Start()
{
cam = Camera.main;
camPosition = cam.transform.position;
}
void Update()
{
myPoint = cam.ScreenToWorldPoint(Input.mousePosition);
}
I tried myPoint = cam.ScreenToWorldPoint(Input.mousePosition) - camPosition ;
but it creates a terrible offset.
So what I try to do is to measure the variation of the x, y, z of the camera’s position and substract it to myPoint, but without its initial values.
in other terms, lets suppose that my camera position is initialy: camPos = (150,-30,0)
and my point position is myPoint = (0,0,0)
then camera moves to theses coordinates: camPos = (180,10,0)
so a variation of (+30,+40,0)
how to make myPoint = (30,40,0) ?
and how to do this for every movement of the camera?
Thanks in advance for your help ![]()