Quantcast
Channel: Latest Questions by MasterBLB
Viewing all articles
Browse latest Browse all 44

Raycast from camera to mesh works incorrectly

$
0
0
Hi all I have a such scene: http://i540.photobucket.com/albums/gg324/MasterBLB/PositionBug1.png Now I want to cast a ray from camera straight forward to find a visual center point on my Earth.I do it by code: RaycastHit hit; Ray ray=Camera.main.ScreenPointToRay(Camera.main.transform.forward); Physics.Raycast(ray,out hit,float.PositiveInfinity); Vector3 center=transform.InverseTransformPoint(hit.point); (Camera is rotated by 180o,but that does not infuence results as I made a check) Yet this gives me unbelievable results,like (-8000,-8000) while something like (600,-0.75) is expected...What's wrong with my code? Moreover,I tried to use Debug.DrawRay() to check how really the ray is cast,but the ray was not visible,no matter if I set "gizmos" option or not :/

Viewing all articles
Browse latest Browse all 44

Trending Articles



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