hi,
i have 3 cameras placed on the scene and user can switch between them. in each of cameras user can drag a wall and place it somewhere that he/she wants.
now the problem is i want the object (wall) to follow mouse on the x-z plane meaning that the transform.z of wall should always be 2f.
the problem is my code works fine on the top camera (all are perspective cameras) but if i switch to other 2 angled cameras, it does not work correctly. these are the position of my cameras :
![alt text][1]
and this is the code for dragging :
Vector3 pos = Input.mousePosition;
Vector3 targetPos = new Vector3 (pos.x, pos.y,gc.activeCam.transform.position.z);
Vector3 worldPos = gc.activeCam.ScreenToWorldPoint (targetPos);
worldPos.y = 2f;
print(worldPos);
transform.position = Vector3.MoveTowards (transform.position, worldPos, 15f * Time.deltaTime);
(i run this code on update so i use MoveTowards)
what is wrong with my code ?
[1]: /storage/temp/85780-screen-shot-1395-10-23-at-32724-pm.png
↧