playMaker

Author Topic: Screen to World space exactly where mouse is  (Read 1765 times)

zorranco

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Screen to World space exactly where mouse is
« on: February 04, 2015, 08:32:27 AM »
Hello, I have followed the official tutorial about screen to world, and my setup is the same as in the video. The camera is a top-down style that follows player as shown in screenshot:



The machine is:



Problem is there is always an offset between the cursor in 3d space (blue circle) and the real position of the mouse cursor in screen. I want both to be exacly same so for example when I click, character moves to that position (this is not exactly what I want, but to say).

Screen to world space action has a  ScreenZ value of 10, I tried to do raycast from near clip plane of camera to blue circle and get distance (ok), then feed this distance to Screen Z, but I think there's little more math to do so both pointers (real mouse and blue circle) are exactly in the same position.

This offset is bigger the more far you get from camera...this is why I think it is related withj Screen Z but I don't know exactly what maths must be done UU'
« Last Edit: February 04, 2015, 08:42:36 AM by zorranco »

KawwaK

  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
Re: Screen to World space exactly where mouse is
« Reply #1 on: February 04, 2015, 02:36:18 PM »
I'm not an expert but in the Screen to world action are you using the same variable for Screen X and for Store World X? They are supoused to be diferent ones, right?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Screen to World space exactly where mouse is
« Reply #2 on: February 04, 2015, 03:18:21 PM »
You're putting Mouse Y into World Z. I don't think that will work.

zorranco

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Re: Screen to World space exactly where mouse is
« Reply #3 on: February 05, 2015, 02:35:26 AM »
Thanks for answers.

Yes, I put Move Y to World Z because I want my movement of the Y of the mouse be translated to the Z world axis, as youtube tutorial explains. It works, but both cursors are not in the same place.

All in all, don't worry because I have found a solution in action Mouse Pick (which it's name is a little misleading for me, I found it by accident). This action maps the position of the cursor in the world space directly, without any type of conversion like in Screen-to-world-space. You take only X and Z and voilá :D

Thanks for help guys ;)

« Last Edit: February 05, 2015, 02:38:16 AM by zorranco »