- Home /
My ingame avatar's worldspace does not coincide with other objects
I have a 3D world with an avatar. I am tracking the avatar's right hand and once it is hovering a Canvas UI element, I want to interact with that object. My issue is currently to translate these positions properly.
I'm using a GUI script to follow the world position of my mouse, and I am currently also logging the world position of my tiles. Hovering over the tiles with my mouse, gives the same world position.
However, these positions do not correlate with my avatars hand position. I tried to translate my rightHandPosition using ScreenToWorldPoint, but the values are still wrong.
Answer by mathiasvdbend · Mar 31 at 01:57 PM
var anchorPos = RectTransformUtility.WorldToScreenPoint(cam, rightHandPos);
var preciseScreenPointToWorld3 = cam.ScreenToWorldPoint(new Vector3(anchorPos.x, anchorPos.y, cam.nearClipPlane));
This code gave me the proper arm world points.
Your answer
Follow this Question
Related Questions
Return the position(x,y) of the pixel when Clicked a Sprite 1 Answer
Internal coordinates for each object 2 Answers
Add borders to landscape 0 Answers
Game is in Stereo 3D, but I want that the UI looks 2D. Do you know how it works? 1 Answer
UI issue: Getting screen coordinates from a World Space object 1 Answer