Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

object follow mouse on x-z plane with angled camera

$
0
0
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

Viewing all articles
Browse latest Browse all 536

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>